Think its fixed now
This commit is contained in:
		@@ -219,6 +219,7 @@ public class LibsDisguises extends JavaPlugin {
 | 
			
		||||
                    ((Zombie) bukkitEntity).setBaby(true);
 | 
			
		||||
                    disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
 | 
			
		||||
                }
 | 
			
		||||
                disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
 | 
			
		||||
            } catch (Exception ex) {
 | 
			
		||||
                System.out.print("[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name()
 | 
			
		||||
                        + "!");
 | 
			
		||||
 
 | 
			
		||||
@@ -153,9 +153,9 @@ public class DisguiseUtilities {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (isDisguiseInUse(disguise)) {
 | 
			
		||||
                ReflectionManager.setBoundingBox(entity, entityBox, disguiseBox);
 | 
			
		||||
                ReflectionManager.setBoundingBox(entity, entityBox, disguiseBox, disguiseValues.getEntitySize());
 | 
			
		||||
            } else {
 | 
			
		||||
                ReflectionManager.setBoundingBox(entity, disguiseBox, entityBox);
 | 
			
		||||
                ReflectionManager.setBoundingBox(entity, disguiseBox, entityBox, entityValues.getEntitySize());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@ public class DisguiseValues {
 | 
			
		||||
 | 
			
		||||
    private FakeBoundingBox adultBox;
 | 
			
		||||
    private FakeBoundingBox babyBox;
 | 
			
		||||
    private float[] entitySize;
 | 
			
		||||
    private int enumEntitySize;
 | 
			
		||||
    private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>();
 | 
			
		||||
    private Class nmsEntityClass;
 | 
			
		||||
@@ -63,6 +64,10 @@ public class DisguiseValues {
 | 
			
		||||
        return babyBox;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public float[] getEntitySize() {
 | 
			
		||||
        return entitySize;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getEntitySize(double paramDouble) {
 | 
			
		||||
        double d = paramDouble - (((int) Math.floor(paramDouble)) + 0.5D);
 | 
			
		||||
 | 
			
		||||
@@ -123,6 +128,10 @@ public class DisguiseValues {
 | 
			
		||||
        babyBox = newBox;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEntitySize(float[] size) {
 | 
			
		||||
        this.entitySize = size;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setMetaValue(int no, Object value) {
 | 
			
		||||
        metaValues.put(no, value);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -12,15 +12,15 @@ public class FakeBoundingBox {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public double getX() {
 | 
			
		||||
        return xMod / 2;
 | 
			
		||||
        return xMod;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public double getY() {
 | 
			
		||||
        return yMod / 2;
 | 
			
		||||
        return yMod;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public double getZ() {
 | 
			
		||||
        return zMod / 2;
 | 
			
		||||
        return zMod;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ import org.bukkit.Bukkit;
 | 
			
		||||
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 {
 | 
			
		||||
@@ -215,6 +214,18 @@ public class ReflectionManager {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static float[] getSize(Entity entity) {
 | 
			
		||||
        try {
 | 
			
		||||
            float length = getNmsClass("Entity").getField("length").getFloat(getNmsEntity(entity));
 | 
			
		||||
            float width = getNmsClass("Entity").getField("width").getFloat(getNmsEntity(entity));
 | 
			
		||||
            float height = getNmsClass("Entity").getField("height").getFloat(getNmsEntity(entity));
 | 
			
		||||
            return new float[] { length, width, height };
 | 
			
		||||
        } catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Float getSoundModifier(Object entity) {
 | 
			
		||||
        try {
 | 
			
		||||
            soundMethod.setAccessible(true);
 | 
			
		||||
@@ -237,7 +248,7 @@ public class ReflectionManager {
 | 
			
		||||
        return after17;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setBoundingBox(Entity entity, FakeBoundingBox oldBox, FakeBoundingBox newBox) {
 | 
			
		||||
    public static void setBoundingBox(Entity entity, FakeBoundingBox oldBox, FakeBoundingBox newBox, float[] entitySize) {
 | 
			
		||||
        try {
 | 
			
		||||
            Object boundingBox = getNmsClass("Entity").getField("boundingBox").get(getNmsEntity(entity));
 | 
			
		||||
            int stage = 0;
 | 
			
		||||
@@ -247,16 +258,16 @@ public class ReflectionManager {
 | 
			
		||||
                    stage++;
 | 
			
		||||
                    switch (stage) {
 | 
			
		||||
                    case 1:
 | 
			
		||||
                        x = field.getDouble(boundingBox) + oldBox.getX();
 | 
			
		||||
                        field.setDouble(boundingBox, x - newBox.getX());
 | 
			
		||||
                        x = field.getDouble(boundingBox); //+ oldBox.getX();
 | 
			
		||||
                 //       field.setDouble(boundingBox, x - newBox.getX());
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 2:
 | 
			
		||||
                        y = field.getDouble(boundingBox) + oldBox.getY();
 | 
			
		||||
                        field.setDouble(boundingBox, y - newBox.getY());
 | 
			
		||||
                        y = field.getDouble(boundingBox);// + oldBox.getY();
 | 
			
		||||
                   //     field.setDouble(boundingBox, y - newBox.getY());
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 3:
 | 
			
		||||
                        z = field.getDouble(boundingBox) + oldBox.getZ();
 | 
			
		||||
                        field.setDouble(boundingBox, z - newBox.getZ());
 | 
			
		||||
                        z = field.getDouble(boundingBox); //+ oldBox.getZ();
 | 
			
		||||
                   //     field.setDouble(boundingBox, z - newBox.getZ());
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 4:
 | 
			
		||||
                        field.setDouble(boundingBox, x + newBox.getX());
 | 
			
		||||
@@ -272,10 +283,17 @@ public class ReflectionManager {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (entity.getType() != EntityType.PLAYER) {
 | 
			
		||||
                // entity.teleport(entity.getLocation().clone()
 | 
			
		||||
                // .subtract(oldBox.getX() - newBox.getX(), oldBox.getY() - newBox.getY(), oldBox.getZ() - newBox.getZ()));
 | 
			
		||||
            }
 | 
			
		||||
            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]);
 | 
			
		||||
            getNmsClass("Entity").getField("width").setFloat(getNmsEntity(entity), size[1]);
 | 
			
		||||
            getNmsClass("Entity").getField("height").setFloat(getNmsEntity(entity), size[2]);
 | 
			
		||||
        } catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user