Clean up. Fix code. Remove useless code.

This commit is contained in:
libraryaddict 2013-12-31 20:08:14 +13:00
parent 2b3657b7b4
commit a7e7097666
3 changed files with 21 additions and 34 deletions

View File

@ -136,26 +136,27 @@ public class DisguiseUtilities {
// TODO Slimes // TODO Slimes
Entity entity = disguise.getEntity(); Entity entity = disguise.getEntity();
if (entity != null) { 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)) { 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 { } 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());
} }
} }
} }

View File

@ -16,7 +16,7 @@ public class FakeBoundingBox {
} }
public double getY() { public double getY() {
return yMod / 2; return yMod;
} }
public double getZ() { public double getZ() {

View File

@ -10,7 +10,6 @@ import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class ReflectionManager { public class ReflectionManager {
@ -250,7 +249,7 @@ public class ReflectionManager {
return after17; 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 { try {
Object boundingBox = getNmsClass("Entity").getField("boundingBox").get(getNmsEntity(entity)); Object boundingBox = getNmsClass("Entity").getField("boundingBox").get(getNmsEntity(entity));
int stage = 0; 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) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }