diff options
author | EvilSeph <evilseph@gmail.com> | 2012-04-20 00:28:30 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-04-21 00:45:30 -0400 |
commit | 8f6fe0a643fa6b8d86bcbb84771c2ad2398b8771 (patch) | |
tree | 04df7ac31fdd7ebd1e35071322f12927327e1292 /src/main/java/net/minecraft/server/Entity.java | |
parent | 3e15a6911f1a2b6ff9401a3c6058d3c361b0fb17 (diff) | |
download | craftbukkit-8f6fe0a643fa6b8d86bcbb84771c2ad2398b8771.tar craftbukkit-8f6fe0a643fa6b8d86bcbb84771c2ad2398b8771.tar.gz craftbukkit-8f6fe0a643fa6b8d86bcbb84771c2ad2398b8771.tar.lz craftbukkit-8f6fe0a643fa6b8d86bcbb84771c2ad2398b8771.tar.xz craftbukkit-8f6fe0a643fa6b8d86bcbb84771c2ad2398b8771.zip |
Rework clipping logic again, now works as well as the original implementation
Diffstat (limited to 'src/main/java/net/minecraft/server/Entity.java')
-rw-r--r-- | src/main/java/net/minecraft/server/Entity.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 1f3046c8..4c5758b8 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -22,9 +22,65 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.plugin.PluginManager; +import org.bukkit.util.NumberConversions; // CraftBukkit end public abstract class Entity { + // CraftBukkit start - size of entity for clipping calculations + public enum EntitySize { + SIZE_1, + SIZE_2, + SIZE_3, + SIZE_4, + SIZE_5, + SIZE_6; + + public int getXZCoord(double loc) { + double diff = loc - (NumberConversions.floor(loc) + 0.5D); + + switch (this) { + case SIZE_1: + if (diff < 0.0D ? diff < -0.3125D : diff < 0.3125D) { + return NumberConversions.ceil(loc * 32.0D); + } + + return NumberConversions.floor(loc * 32.0D); + case SIZE_2: + if (diff < 0.0D ? diff < -0.3125D : diff < 0.3125D) { + return NumberConversions.floor(loc * 32.0D); + } + + return NumberConversions.ceil(loc * 32.0D); + case SIZE_3: + if (diff > 0.0D) { + return NumberConversions.floor(loc * 32.0D); + } + + return NumberConversions.ceil(loc * 32.0D); + case SIZE_4: + if (diff < 0.0D ? diff < -0.1875D : diff < 0.1875D) { + return NumberConversions.ceil(loc * 32.0D); + } + + return NumberConversions.floor(loc * 32.0D); + case SIZE_5: + if (diff < 0.0D ? diff < -0.1875D : diff < 0.1875D) { + return NumberConversions.floor(loc * 32.0D); + } + + return NumberConversions.ceil(loc * 32.0D); + case SIZE_6: + default: + if (diff > 0.0D) { + return NumberConversions.ceil(loc * 32.0D); + } + + return NumberConversions.floor(loc * 32.0D); + } + } + } + public EntitySize size; + // CraftBukkit end private static int entityCount = 0; public int id; @@ -100,6 +156,7 @@ public abstract class Entity { this.dead = false; this.height = 0.0F; this.width = 0.6F; + this.size = EntitySize.SIZE_2; // CraftBukkit this.length = 1.8F; this.bI = 0.0F; this.bJ = 0.0F; @@ -147,6 +204,22 @@ public abstract class Entity { protected void b(float f, float f1) { this.width = f; this.length = f1; + // CraftBukkit start - figure out entity size for clipping calculations + float mod = f % 2f; + if (mod < 0.375) { + this.size = EntitySize.SIZE_1; + } else if (mod < 0.75) { + this.size = EntitySize.SIZE_2; + } else if (mod < 1.0) { + this.size = EntitySize.SIZE_3; + } else if (mod < 1.375) { + this.size = EntitySize.SIZE_4; + } else if (mod < 1.75) { + this.size = EntitySize.SIZE_5; + } else { + this.size = EntitySize.SIZE_6; + } + // CraftBukkit end } protected void c(float f, float f1) { |