diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-03-25 21:22:03 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-03-25 21:22:03 +0100 |
commit | 9162a654c44801ee40e47a7dad94cc7a7c95afed (patch) | |
tree | 647e8ec79a227fbb0f8c3d4e3bba51cd5edfe2d8 /src | |
parent | 6fc4d9dcfe7a1eeeefd219aeee4a07f964b391d7 (diff) | |
download | craftbukkit-9162a654c44801ee40e47a7dad94cc7a7c95afed.tar craftbukkit-9162a654c44801ee40e47a7dad94cc7a7c95afed.tar.gz craftbukkit-9162a654c44801ee40e47a7dad94cc7a7c95afed.tar.lz craftbukkit-9162a654c44801ee40e47a7dad94cc7a7c95afed.tar.xz craftbukkit-9162a654c44801ee40e47a7dad94cc7a7c95afed.zip |
Implement player.getCompassTarget
Diffstat (limited to 'src')
4 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 1c532764..6ec75601 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -7,6 +7,8 @@ import java.util.Set; // CraftBukkit start import java.util.ArrayList; + +import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.CraftEntity; @@ -56,6 +58,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public String displayName; + public Location compassTarget; // CraftBukkit end public void l() { diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 254c682d..fd17fd30 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -63,8 +63,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener { Long lastPacket; // Store the last block right clicked and what type it was - private CraftBlock lastRightClicked; - private BlockFace lastRightClickedFace; private int lastMaterial; public CraftPlayer getPlayer() { @@ -513,6 +511,12 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } public void b(Packet packet) { + // CraftBukkit + if (packet instanceof Packet6SpawnPosition) { + Packet6SpawnPosition packet6 = (Packet6SpawnPosition) packet; + this.e.compassTarget = new Location(getPlayer().getWorld(), packet6.a, packet6.b, packet6.c); + } + // CraftBukkit this.b.a(packet); this.g = this.f; } diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index f752e8b4..34ac6497 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -171,6 +171,7 @@ public class ServerConfigurationManager { entityplayer1.id = entityplayer.id; entityplayer1.a = entityplayer.a; entityplayer1.displayName = entityplayer.displayName; // CraftBukkit + entityplayer1.compassTarget = entityplayer.compassTarget; // CraftBukkit ((WorldServer) entityplayer.world).u.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); while (entityplayer.world.a(entityplayer1, entityplayer1.boundingBox).size() != 0) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index ef90643e..adc09118 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -125,7 +125,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void setCompassTarget(Location loc) { - getHandle().a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())))); + // Do not directly assign here, from the packethandler we'll assign it. + getHandle().a.b((Packet) new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + } + + public Location getCompassTarget() { + return getHandle().compassTarget; } public void chat(String msg) { @@ -159,6 +164,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { newEntity.locX = location.getX(); newEntity.locY = location.getY(); newEntity.locZ = location.getZ(); + newEntity.compassTarget = entity.compassTarget; newWorld.u.d((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4); teleportSuccess = newEntity.a.teleport(location); @@ -176,6 +182,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { entity.a.e = newEntity; this.entity = newEntity; + + setCompassTarget(getCompassTarget()); } return teleportSuccess; |