diff --git a/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java
index c6a7cca..558a190 100644
--- a/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java
+++ b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java
@@ -983,4 +983,17 @@
{
return renderDistance;
}
+
+ /**
+ * Переносит игрока в другой мир без использования порталов. Обратите
+ * внимение: сначала нужно установить координаты назначения
+ * setPlayerLocation()
, а потом уже переносить в другой мир.
+ */
+ public void transferToDimension(int dim)
+ {
+ this.mcServer.getConfigurationManager().transferPlayerToDimension(this, dim, null);
+ this.lastExperience = -1;
+ this.lastHealth = -1.0F;
+ this.lastFoodLevel = -1;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java
index 3f79c5b..ed57fbe 100644
--- a/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java
+++ b/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java
@@ -537,47 +537,59 @@
}
}
*/
- if (par1Entity.dimension == 1)
+ if(teleporter != null)
{
- ChunkCoordinates chunkcoordinates;
-
- if (par2 == 1)
+ if (par1Entity.dimension == 1)
{
- chunkcoordinates = par4WorldServer.getSpawnPoint();
- }
- else
- {
- chunkcoordinates = par4WorldServer.getEntrancePortalLocation();
- }
+ ChunkCoordinates chunkcoordinates;
- d0 = (double)chunkcoordinates.posX;
- par1Entity.posY = (double)chunkcoordinates.posY;
- d1 = (double)chunkcoordinates.posZ;
- par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, 90.0F, 0.0F);
+ if (par2 == 1)
+ {
+ chunkcoordinates = par4WorldServer.getSpawnPoint();
+ }
+ else
+ {
+ chunkcoordinates = par4WorldServer.getEntrancePortalLocation();
+ }
- if (par1Entity.isEntityAlive())
- {
- par3WorldServer.updateEntityWithOptionalForce(par1Entity, false);
- }
- }
+ d0 = (double)chunkcoordinates.posX;
+ par1Entity.posY = (double)chunkcoordinates.posY;
+ d1 = (double)chunkcoordinates.posZ;
+ par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, 90.0F, 0.0F);
- par3WorldServer.theProfiler.endSection();
-
- if (par2 != 1)
- {
- par3WorldServer.theProfiler.startSection("placing");
- d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872);
- d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872);
-
- if (par1Entity.isEntityAlive())
- {
- par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, par1Entity.rotationYaw, par1Entity.rotationPitch);
- teleporter.placeInPortal(par1Entity, d3, d4, d5, f);
- par4WorldServer.spawnEntityInWorld(par1Entity);
- par4WorldServer.updateEntityWithOptionalForce(par1Entity, false);
+ if (par1Entity.isEntityAlive())
+ {
+ par3WorldServer.updateEntityWithOptionalForce(par1Entity, false);
+ }
}
par3WorldServer.theProfiler.endSection();
+
+ if (par2 != 1)
+ {
+ par3WorldServer.theProfiler.startSection("placing");
+ d0 = (double)MathHelper.clamp_int((int)d0, -(World.MAX_BLOCK_COORD - 128), World.MAX_BLOCK_COORD - 128);
+ d1 = (double)MathHelper.clamp_int((int)d1, -(World.MAX_BLOCK_COORD - 128), World.MAX_BLOCK_COORD - 128);
+
+ if (par1Entity.isEntityAlive())
+ {
+ par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, par1Entity.rotationYaw, par1Entity.rotationPitch);
+ teleporter.placeInPortal(par1Entity, d3, d4, d5, f);
+ par4WorldServer.spawnEntityInWorld(par1Entity);
+ par4WorldServer.updateEntityWithOptionalForce(par1Entity, false);
+ }
+
+ par3WorldServer.theProfiler.endSection();
+ }
+ }
+ else
+ {
+ par3WorldServer.theProfiler.endSection();
+ if (par1Entity.isEntityAlive())
+ {
+ par4WorldServer.spawnEntityInWorld(par1Entity);
+ par4WorldServer.updateEntityWithOptionalForce(par1Entity, false);
+ }
}
par1Entity.setWorld(par4WorldServer);
diff --git a/src/main/java/org/ultramine/commands/basic/TeleportCommands.java b/src/main/java/org/ultramine/commands/basic/TeleportCommands.java
new file mode 100644
index 0000000..b84a5a5
--- /dev/null
+++ b/src/main/java/org/ultramine/commands/basic/TeleportCommands.java
@@ -0,0 +1,42 @@
+package org.ultramine.commands.basic;
+
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.world.WorldServer;
+
+import org.ultramine.commands.Command;
+import org.ultramine.commands.CommandContext;
+import org.ultramine.server.Teleporter;
+
+public class TeleportCommands
+{
+ @Command(
+ name = "tp",
+ group = "basic",
+ aliases = {"tppos", "tpposp", "tpto"},
+ permissions = {"basic.tp"},
+ syntax = {
+ "",
+ " ",
+ "<%x> <%y> <%z>",
+ " <%x> <%y> <%z>",
+ " <%x> <%y> <%z>",
+ " <%x> <%y> <%z>"
+ }
+ )
+ public static void tp(CommandContext context)
+ {
+ EntityPlayerMP target = context.contains("target") ? context.get("target").asPlayer() : context.getSenderAsPlayer();
+ if(context.contains("dst"))
+ {
+ Teleporter.tpNow(target, context.get("dst").asPlayer());
+ }
+ else if(context.contains("x") && context.contains("y") && context.contains("z"))
+ {
+ WorldServer world = context.contains("world") ? context.get("world").asWorld() : target.getServerForPlayer();
+ double x = context.get("x").asCoordinate(target.posX);
+ double y = context.get("y").asCoordinate(target.posY);
+ double z = context.get("z").asCoordinate(target.posZ);
+ Teleporter.tpNow(target, world.provider.dimensionId, x, y, z);
+ }
+ }
+}
diff --git a/src/main/java/org/ultramine/server/Teleporter.java b/src/main/java/org/ultramine/server/Teleporter.java
new file mode 100644
index 0000000..040466e
--- /dev/null
+++ b/src/main/java/org/ultramine/server/Teleporter.java
@@ -0,0 +1,47 @@
+package org.ultramine.server;
+
+import org.ultramine.server.util.WarpLocation;
+
+import net.minecraft.entity.player.EntityPlayerMP;
+
+public class Teleporter
+{
+ public static void tpNow(EntityPlayerMP target, EntityPlayerMP dst)
+ {
+ if(target == null || dst == null) return;
+ doTeleportation(target, dst.worldObj.provider.dimensionId, dst.posX, dst.posY, dst.posZ, dst.rotationYaw, dst.rotationPitch);
+ }
+
+ public static void tpNow(EntityPlayerMP target, double x, double y, double z)
+ {
+ if(target == null) return;
+ doTeleportation(target, target.worldObj.provider.dimensionId, x, y, z, target.rotationYaw, target.rotationPitch);
+ }
+
+ public static void tpNow(EntityPlayerMP target, int dimension, double x, double y, double z)
+ {
+ if(target == null) return;
+ doTeleportation(target, dimension, x, y, z, target.rotationYaw, target.rotationPitch);
+ }
+
+ public static void tpNow(EntityPlayerMP target, WarpLocation dst)
+ {
+ if(target == null || dst == null) return;
+ doTeleportation(target, dst.dimension, dst.x, dst.y, dst.z, dst.yaw, dst.pitch);
+ }
+
+ private static void doTeleportation(EntityPlayerMP player, int dimension, double x, double y, double z, float yaw, float pitch)
+ {
+ //player.getPlayerData().lastLocation = WarpLocation.getFromPlayer(player);
+
+ player.playerNetServerHandler.setPlayerLocation(x, y, z, yaw, pitch);
+
+ if(player.dimension != dimension)
+ {
+ player.transferToDimension(dimension);
+ }
+
+ //player.getPlayerData().onTeleport();
+ //player.getPlayerData().teleport = null;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/util/WarpLocation.java b/src/main/java/org/ultramine/server/util/WarpLocation.java
new file mode 100644
index 0000000..aee9522
--- /dev/null
+++ b/src/main/java/org/ultramine/server/util/WarpLocation.java
@@ -0,0 +1,61 @@
+package org.ultramine.server.util;
+
+import net.minecraft.entity.player.EntityPlayer;
+
+public class WarpLocation
+{
+ public int dimension;
+ public double x;
+ public double y;
+ public double z;
+ public float yaw;
+ public float pitch;
+ public double randomRadius;
+
+ public WarpLocation(int dimension, double x, double y, double z, float yaw, float pitch, double randomRadius)
+ {
+ this.dimension = dimension;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.yaw = yaw;
+ this.pitch = pitch;
+ this.randomRadius = randomRadius;
+ }
+
+ public WarpLocation(int dimension, double x, double y, double z, float yaw, float pitch)
+ {
+ this(dimension, x, y, z, yaw, pitch, 0);
+ }
+
+ public WarpLocation(int dimension, double x, double y, double z)
+ {
+ this(dimension, x, y, z, 0, 0);
+ }
+
+ public void round()
+ {
+ x = (double)Math.round(x*100)/100.0;
+ y = (double)Math.round(y*100)/100.0;
+ z = (double)Math.round(z*100)/100.0;
+
+ yaw = (float)Math.round(yaw*100)/100.0F;
+ pitch = (float)Math.round(pitch*100)/100.0F;
+ }
+
+ public boolean equals(WarpLocation loc)
+ {
+ if(this == loc) return true;
+ return
+ Math.abs(x - loc.x) < 0.1 &&
+ Math.abs(y - loc.y) < 0.1 &&
+ Math.abs(z - loc.z) < 0.1;
+ }
+
+ public static WarpLocation getFromPlayer(EntityPlayer player)
+ {
+ WarpLocation s = new WarpLocation(player.dimension, player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
+ s.round();
+ return s;
+ }
+}