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