From a7e7097666ba640c55d0e0816289cad2acca864f Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 31 Dec 2013 20:08:14 +1300 Subject: [PATCH] Clean up. Fix code. Remove useless code. --- .../disguise/utilities/DisguiseUtilities.java | 37 ++++++++++--------- .../disguise/utilities/FakeBoundingBox.java | 2 +- .../disguise/utilities/ReflectionManager.java | 16 +------- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index d375230a..9bb900c2 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -136,26 +136,27 @@ public class DisguiseUtilities { // TODO Slimes Entity entity = disguise.getEntity(); if (entity != null) { - DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType()); - DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType())); - FakeBoundingBox entityBox = entityValues.getAdultBox(); - FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); - if (entityValues.getBabyBox() != null) { - if (entity instanceof Ageable && !(((Ageable) entity).isAdult()) - || (entity instanceof Zombie && ((Zombie) entity).isBaby())) { - entityBox = entityValues.getBabyBox(); - } - } - if (disguiseValues.getBabyBox() != null) { - if (disguise.getWatcher() instanceof AgeableWatcher && (((AgeableWatcher) disguise.getWatcher()).isBaby()) - || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher()).isBaby())) { - disguiseBox = disguiseValues.getBabyBox(); - } - } if (isDisguiseInUse(disguise)) { - ReflectionManager.setBoundingBox(entity, entityBox, disguiseBox, disguiseValues.getEntitySize()); + DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType()); + FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); + if (disguiseValues.getBabyBox() != null) { + if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby()) + || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher()) + .isBaby())) { + disguiseBox = disguiseValues.getBabyBox(); + } + } + ReflectionManager.setBoundingBox(entity, disguiseBox, disguiseValues.getEntitySize()); } else { - ReflectionManager.setBoundingBox(entity, disguiseBox, entityBox, entityValues.getEntitySize()); + DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType())); + FakeBoundingBox entityBox = entityValues.getAdultBox(); + if (entityValues.getBabyBox() != null) { + if ((entity instanceof Ageable && !((Ageable) entity).isAdult()) + || (entity instanceof Zombie && ((Zombie) entity).isBaby())) { + entityBox = entityValues.getBabyBox(); + } + } + ReflectionManager.setBoundingBox(entity, entityBox, entityValues.getEntitySize()); } } } diff --git a/src/me/libraryaddict/disguise/utilities/FakeBoundingBox.java b/src/me/libraryaddict/disguise/utilities/FakeBoundingBox.java index 59bb3e37..8f92890c 100644 --- a/src/me/libraryaddict/disguise/utilities/FakeBoundingBox.java +++ b/src/me/libraryaddict/disguise/utilities/FakeBoundingBox.java @@ -16,7 +16,7 @@ public class FakeBoundingBox { } public double getY() { - return yMod / 2; + return yMod; } public double getZ() { diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index ae755caa..a3123d73 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -10,7 +10,6 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; public class ReflectionManager { @@ -250,7 +249,7 @@ public class ReflectionManager { return after17; } - public static void setBoundingBox(Entity entity, FakeBoundingBox oldBox, FakeBoundingBox newBox, float[] entitySize) { + public static void setBoundingBox(Entity entity, FakeBoundingBox newBox, float[] entitySize) { try { Object boundingBox = getNmsClass("Entity").getField("boundingBox").get(getNmsEntity(entity)); int stage = 0; @@ -282,19 +281,6 @@ public class ReflectionManager { } } } - // setSize(entity, entitySize); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - public static void setSize(Entity entity, float[] size) { - try { - getNmsClass("Entity").getField("length").setFloat(getNmsEntity(entity), size[0]); - if (entity.getType() != EntityType.PLAYER) { - getNmsClass("Entity").getField("width").setFloat(getNmsEntity(entity), size[1]); - getNmsClass("Entity").getField("height").setFloat(getNmsEntity(entity), size[2]); - } } catch (Exception ex) { ex.printStackTrace(); }