diff --git a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java index 89c6b1b0..8d8799da 100644 --- a/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java +++ b/NCPCompat/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java @@ -46,15 +46,24 @@ public interface MCAccess { public double getHeight(Entity entity); /** - * Return maximum. + * Return some width. * @param entity * @return */ - public double getWidthOrLength(Entity entity); - + public double getWidth(Entity entity); + /** + * NMS Block static. + * @param id + * @return + */ public AlmostBoolean isBlockSolid(int id); + /** + * NMS Block static.. + * @param id + * @return + */ public AlmostBoolean isBlockLiquid(int id); /** @@ -93,6 +102,11 @@ public interface MCAccess { public void dealFallDamage(Player player, int damage); + /** + * This may well be removed, if possible to check with Bukkit. + * @param damaged + * @return + */ public boolean isComplexPart(Entity damaged); /** diff --git a/NCPCompatCB2511/src/main/java/fr/neatmonster/nocheatplus/compat/cb2511/MCAccessCB2511.java b/NCPCompatCB2511/src/main/java/fr/neatmonster/nocheatplus/compat/cb2511/MCAccessCB2511.java index b29612b0..16357909 100644 --- a/NCPCompatCB2511/src/main/java/fr/neatmonster/nocheatplus/compat/cb2511/MCAccessCB2511.java +++ b/NCPCompatCB2511/src/main/java/fr/neatmonster/nocheatplus/compat/cb2511/MCAccessCB2511.java @@ -54,7 +54,7 @@ public class MCAccessCB2511 implements MCAccess { @Override public double getHeight(final Entity entity) { final net.minecraft.server.Entity mcEntity = ((CraftEntity) entity).getHandle(); - final double entityHeight = Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b); + final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b)); if (entity instanceof LivingEntity) { return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight); } else return entityHeight; @@ -86,9 +86,8 @@ public class MCAccessCB2511 implements MCAccess { } @Override - public double getWidthOrLength(final Entity entity) { - final net.minecraft.server.Entity mcEntity = ((CraftEntity) entity).getHandle(); - return Math.max(mcEntity.width, mcEntity.length); + public double getWidth(final Entity entity) { + return ((CraftEntity) entity).getHandle().width; } @Override diff --git a/NCPCompatCB2512/src/main/java/fr/neatmonster/nocheatplus/compat/cb2512/MCAccessCB2512.java b/NCPCompatCB2512/src/main/java/fr/neatmonster/nocheatplus/compat/cb2512/MCAccessCB2512.java index 7e210dd9..55494288 100644 --- a/NCPCompatCB2512/src/main/java/fr/neatmonster/nocheatplus/compat/cb2512/MCAccessCB2512.java +++ b/NCPCompatCB2512/src/main/java/fr/neatmonster/nocheatplus/compat/cb2512/MCAccessCB2512.java @@ -53,7 +53,7 @@ public class MCAccessCB2512 implements MCAccess{ @Override public double getHeight(final Entity entity) { final net.minecraft.server.v1_4_5.Entity mcEntity = ((CraftEntity) entity).getHandle(); - final double entityHeight = Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b); + final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b)); if (entity instanceof LivingEntity) { return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight); } else return entityHeight; @@ -85,9 +85,8 @@ public class MCAccessCB2512 implements MCAccess{ } @Override - public double getWidthOrLength(final Entity entity) { - final net.minecraft.server.v1_4_5.Entity mcEntity = ((CraftEntity) entity).getHandle(); - return Math.max(mcEntity.width, mcEntity.length); + public double getWidth(final Entity entity) { + return ((CraftEntity) entity).getHandle().width; } @Override diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Direction.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Direction.java index 870bcf5a..ed4a30c4 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Direction.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Direction.java @@ -51,7 +51,7 @@ public class Direction extends Check { return false; // Find out how wide the entity is. - final double width = mcAccess.getWidthOrLength(damaged); + final double width = mcAccess.getWidth(damaged); // entity.height is broken and will always be 0, therefore. Calculate height instead based on boundingBox. final double height = mcAccess.getHeight(damaged); diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index 0e5066df..4470e9f1 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -526,9 +526,8 @@ public class PlayerLocation { // maxY = y + entityPlayer.boundingBox.e + dY; // maxZ = z + entityPlayer.boundingBox.f + dZ; // // TODO: inset, outset ? - this.width = mcAccess.getWidthOrLength(player); + this.width = mcAccess.getWidth(player); final double dxz = this.width / 2; - // final double dX = (entityPlayer.boundingBox.d - entityPlayer.boundingBox.a) / 2D; // final double dY = entityPlayer.boundingBox.e - entityPlayer.boundingBox.b; // final double dZ = (entityPlayer.boundingBox.f - entityPlayer.boundingBox.c) / 2D;