Clean up. Fix code. Remove useless code.
This commit is contained in:
parent
2b3657b7b4
commit
a7e7097666
@ -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) {
|
||||||
|
if (isDisguiseInUse(disguise)) {
|
||||||
DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
|
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 {
|
||||||
DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
|
DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
|
||||||
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
||||||
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
|
||||||
if (entityValues.getBabyBox() != null) {
|
if (entityValues.getBabyBox() != null) {
|
||||||
if (entity instanceof Ageable && !(((Ageable) entity).isAdult())
|
if ((entity instanceof Ageable && !((Ageable) entity).isAdult())
|
||||||
|| (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
|| (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
||||||
entityBox = entityValues.getBabyBox();
|
entityBox = entityValues.getBabyBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (disguiseValues.getBabyBox() != null) {
|
ReflectionManager.setBoundingBox(entity, entityBox, entityValues.getEntitySize());
|
||||||
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());
|
|
||||||
} else {
|
|
||||||
ReflectionManager.setBoundingBox(entity, disguiseBox, entityBox, entityValues.getEntitySize());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class FakeBoundingBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return yMod / 2;
|
return yMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user