From a9191c24b333d3c6bb395b92a3a12edec06e78a7 Mon Sep 17 00:00:00 2001 From: Dinnerbone <dinnerbone@dinnerbone.com> Date: Thu, 30 Dec 2010 20:34:26 +0000 Subject: [PATCH] Fixed insane fall damage (entities reset on death) --- .../minecraft/server/NetServerHandler.java | 21 +++++++++------- src/org/bukkit/craftbukkit/CraftEntity.java | 6 ++++- .../bukkit/craftbukkit/CraftHumanEntity.java | 7 +++++- .../bukkit/craftbukkit/CraftLivingEntity.java | 8 ++++++- src/org/bukkit/craftbukkit/CraftPlayer.java | 24 +++++++++++++++++++ src/org/bukkit/craftbukkit/CraftWorld.java | 5 ++++ 6 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/net/minecraft/server/NetServerHandler.java b/src/net/minecraft/server/NetServerHandler.java index 02ac31d70e..1168a6dfd0 100644 --- a/src/net/minecraft/server/NetServerHandler.java +++ b/src/net/minecraft/server/NetServerHandler.java @@ -81,17 +81,19 @@ public class NetServerHandler extends NetHandler // CraftBukkit start Location from = new Location(player.getWorld(), g, h, i, e.v, e.w); Location to = player.getLocation(); - PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_MOVE, player, from, to); - server.getPluginManager().callEvent(event); + if (!from.equals(to)) { + PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_MOVE, player, from, to); + server.getPluginManager().callEvent(event); - from = event.getFrom(); - to = event.isCancelled() ? from : event.getTo(); + from = event.getFrom(); + to = event.isCancelled() ? from : event.getTo(); - e.p = to.getX(); - e.q = to.getY(); - e.r = to.getZ(); - e.v = to.getYaw(); - e.w = to.getPitch(); + e.p = to.getX(); + e.q = to.getY(); + e.r = to.getZ(); + e.v = to.getYaw(); + e.w = to.getPitch(); + } // CraftBukkit end if (j) { @@ -481,6 +483,7 @@ public class NetServerHandler extends NetHandler return; } else { e = d.f.d(e); + player.setHandle(e); // CraftBukkit return; } } diff --git a/src/org/bukkit/craftbukkit/CraftEntity.java b/src/org/bukkit/craftbukkit/CraftEntity.java index 2a2f2392e7..efbb7f2866 100644 --- a/src/org/bukkit/craftbukkit/CraftEntity.java +++ b/src/org/bukkit/craftbukkit/CraftEntity.java @@ -8,7 +8,7 @@ import org.bukkit.World; public class CraftEntity implements org.bukkit.Entity { protected final CraftServer server; - private final Entity entity; + private Entity entity; public CraftEntity(final CraftServer server, final Entity entity) { this.server = server; @@ -35,6 +35,10 @@ public class CraftEntity implements org.bukkit.Entity { return entity; } + public void setHandle(final Entity entity) { + this.entity = entity; + } + @Override public boolean equals(Object obj) { if (obj == null) { diff --git a/src/org/bukkit/craftbukkit/CraftHumanEntity.java b/src/org/bukkit/craftbukkit/CraftHumanEntity.java index 1152bc62f4..b03f096725 100644 --- a/src/org/bukkit/craftbukkit/CraftHumanEntity.java +++ b/src/org/bukkit/craftbukkit/CraftHumanEntity.java @@ -7,7 +7,7 @@ import org.bukkit.HumanEntity; import org.bukkit.ItemStack; public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { - private final EntityPlayer entity; + private EntityPlayer entity; public CraftHumanEntity(final CraftServer server, final EntityPlayer entity) { super(server, entity); @@ -29,6 +29,11 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return entity; } + public void setHandle(final EntityPlayer entity) { + super.setHandle((EntityPlayer)entity); + this.entity = entity; + } + @Override public String toString() { return "CraftHumanEntity{" + "id=" + getEntityID() + "name=" + getName() + '}'; diff --git a/src/org/bukkit/craftbukkit/CraftLivingEntity.java b/src/org/bukkit/craftbukkit/CraftLivingEntity.java index 2c70d10a08..8f75338699 100644 --- a/src/org/bukkit/craftbukkit/CraftLivingEntity.java +++ b/src/org/bukkit/craftbukkit/CraftLivingEntity.java @@ -1,11 +1,12 @@ package org.bukkit.craftbukkit; +import net.minecraft.server.Entity; import net.minecraft.server.EntityLiving; import org.bukkit.LivingEntity; public class CraftLivingEntity extends CraftEntity implements LivingEntity { - private final EntityLiving entity; + private EntityLiving entity; public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); @@ -29,6 +30,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return entity; } + public void setHandle(final EntityLiving entity) { + super.setHandle((Entity)entity); + this.entity = entity; + } + @Override public String toString() { return "CraftLivingEntity{" + "id=" + getEntityID() + '}'; diff --git a/src/org/bukkit/craftbukkit/CraftPlayer.java b/src/org/bukkit/craftbukkit/CraftPlayer.java index f10d920c19..a8a368dc97 100644 --- a/src/org/bukkit/craftbukkit/CraftPlayer.java +++ b/src/org/bukkit/craftbukkit/CraftPlayer.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit; +import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayerMP; import net.minecraft.server.Packet3Chat; import org.bukkit.Location; @@ -24,6 +25,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void setHandle(final EntityPlayerMP entity) { + super.setHandle((EntityPlayer)entity); this.entity = entity; } @@ -40,4 +42,26 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public String toString() { return "CraftPlayer{" + "name=" + getName() + '}'; } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftPlayer other = (CraftPlayer) obj; + if ((this.getName() == null) ? (other.getName() != null) : !this.getName().equals(other.getName())) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 97 * hash + (this.getName() != null ? this.getName().hashCode() : 0); + return hash; + } } diff --git a/src/org/bukkit/craftbukkit/CraftWorld.java b/src/org/bukkit/craftbukkit/CraftWorld.java index e3d691f846..5e6d20d7ec 100644 --- a/src/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/org/bukkit/craftbukkit/CraftWorld.java @@ -70,6 +70,11 @@ public class CraftWorld implements World { return world; } + @Override + public String toString() { + return "CraftWorld"; + } + private final class ChunkCoordinate { public final int x; public final int z;