diff options
author | EvilSeph <evilseph@gmail.com> | 2012-03-06 19:59:15 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-03-07 23:51:55 -0500 |
commit | 7a8ef4f6a424e907095ac5402cf903e388ad80f8 (patch) | |
tree | 84a98678723a9b13a0fb2fa490f3b4439fccf95b /src/main/java/net/minecraft/server/NetServerHandler.java | |
parent | b5af5adc7e48151f7bed1cb80a69d136f49e5836 (diff) | |
download | craftbukkit-7a8ef4f6a424e907095ac5402cf903e388ad80f8.tar craftbukkit-7a8ef4f6a424e907095ac5402cf903e388ad80f8.tar.gz craftbukkit-7a8ef4f6a424e907095ac5402cf903e388ad80f8.tar.lz craftbukkit-7a8ef4f6a424e907095ac5402cf903e388ad80f8.tar.xz craftbukkit-7a8ef4f6a424e907095ac5402cf903e388ad80f8.zip |
Extremely hackish fix for the entity interactivity issue. Fixes BUKKIT-960
Diffstat (limited to 'src/main/java/net/minecraft/server/NetServerHandler.java')
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index b6e41be8..50f2658c 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -9,6 +9,8 @@ import java.io.UnsupportedEncodingException; import java.util.logging.Level; import java.util.Arrays; import java.util.HashSet; +import java.util.Timer; +import java.util.TimerTask; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.ChunkCompressionThread; @@ -262,7 +264,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (packet10flying.hasPos && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) { // CraftBukkit start - if (packet10flying.x > 1 || packet10flying.z > 1) { + if (Math.abs(packet10flying.x) > 1 || Math.abs(packet10flying.z) > 1) { System.err.println(player.getName() + " was caught trying to crash the server with an invalid position."); player.kickPlayer("Nope!"); return; @@ -415,6 +417,90 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } + // CraftBukkit start - temporary initial join teleport function, houses hacky entity fix. + public void initialJoin(double d0, double d1, double d2, float f, float f1) { + Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1); + + this.teleport(to); + + Timer timer = new Timer(); + final ArrayList<Entity> nearby = new ArrayList<Entity>(); + // Start inline nearby entities + AxisAlignedBB axisalignedbb = player.boundingBox.grow(100, 100, 100); + int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); + int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); + int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); + int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); + + for (int i1 = i; i1 <= j; ++i1) { + for (int j1 = k; j1 <= l; ++j1) { + if (player.world.chunkProvider.isChunkLoaded(i1, j1)) { + player.world.getChunkAt(i1, j1).a(player, axisalignedbb, nearby); + } + } + } + // End inline nearby entities + for (Object entity : nearby) { + if (entity instanceof EntityLiving || entity instanceof EntityMinecart || entity instanceof EntityBoat || entity instanceof IAnimal || entity instanceof EntityPainting) { + player.netServerHandler.sendPacket(new Packet29DestroyEntity(((Entity) entity).id)); + } + } + + timer.schedule(new TimerTask(){ + public void run() { + // Start inline nearby entities + nearby.clear(); + AxisAlignedBB axisalignedbb = player.boundingBox.grow(100, 100, 100); + int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); + int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); + int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); + int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); + + for (int i1 = i; i1 <= j; ++i1) { + for (int j1 = k; j1 <= l; ++j1) { + if (player.world.chunkProvider.isChunkLoaded(i1, j1)) { + player.world.getChunkAt(i1, j1).a(player, axisalignedbb, nearby); + } + } + } + // End inline nearby entities + for (Object entityObject2 : nearby) { + try { + Entity entity = (Entity) entityObject2; + + if (entity instanceof EntityPlayer) { + player.netServerHandler.sendPacket(new Packet20NamedEntitySpawn((EntityHuman) entity)); + } else if (entity instanceof EntityMinecart) { + EntityMinecart entityminecart = (EntityMinecart) entity; + + if (entityminecart.type == 0) { + player.netServerHandler.sendPacket(new Packet23VehicleSpawn(entity, 10)); + } + + if (entityminecart.type == 1) { + player.netServerHandler.sendPacket(new Packet23VehicleSpawn(entity, 11)); + } + + if (entityminecart.type == 2) { + player.netServerHandler.sendPacket(new Packet23VehicleSpawn(entity, 12)); + } + } else if (entity instanceof EntityBoat) { + player.netServerHandler.sendPacket(new Packet23VehicleSpawn(entity, 1)); + } else if (entity instanceof IAnimal) { + player.netServerHandler.sendPacket(new Packet24MobSpawn((EntityLiving) entity)); + } else if (entity instanceof EntityEnderDragon) { + player.netServerHandler.sendPacket(new Packet24MobSpawn((EntityLiving) entity)); + } else if (entity instanceof EntityPainting) { + player.netServerHandler.sendPacket(new Packet25EntityPainting((EntityPainting) entity)); + } + } catch (ClassCastException e) { + } + } + } + }, 5000); + } + // CraftBukkit end + public void a(double d0, double d1, double d2, float f, float f1) { // CraftBukkit start - Delegate to teleport(Location) Player player = this.getPlayer(); |