Fix bounding boxes

This commit is contained in:
libraryaddict 2018-10-24 11:09:16 +13:00
parent 1c04576ae3
commit dda362f082
2 changed files with 57 additions and 52 deletions

View File

@ -455,7 +455,10 @@ public class DisguiseUtilities {
public static void doBoundingBox(TargetedDisguise disguise) { public static void doBoundingBox(TargetedDisguise disguise) {
Entity entity = disguise.getEntity(); Entity entity = disguise.getEntity();
if (entity != null) { if (entity == null) {
return;
}
if (isDisguiseInUse(disguise)) { if (isDisguiseInUse(disguise)) {
DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType()); DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
@ -485,7 +488,6 @@ public class DisguiseUtilities {
ReflectionManager.setBoundingBox(entity, entityBox); ReflectionManager.setBoundingBox(entity, entityBox);
} }
} }
}
public static int getChunkCord(int blockCord) { public static int getChunkCord(int blockCord) {
int cord = (int) Math.floor(blockCord / 16D) - 17; int cord = (int) Math.floor(blockCord / 16D) - 17;

View File

@ -187,7 +187,10 @@ public class ReflectionManager {
int stage = 0; int stage = 0;
for (Field field : boundingBox.getClass().getDeclaredFields()) { for (Field field : boundingBox.getClass().getDeclaredFields()) {
if (field.getType().getSimpleName().equals("double")) { if (!field.getType().getSimpleName().equals("double")) {
continue;
}
stage++; stage++;
switch (stage) { switch (stage) {
@ -213,7 +216,6 @@ public class ReflectionManager {
throw new Exception("Error while setting the bounding box, more doubles than I thought??"); throw new Exception("Error while setting the bounding box, more doubles than I thought??");
} }
} }
}
return new FakeBoundingBox(x, y, z); return new FakeBoundingBox(x, y, z);
} }
@ -618,8 +620,9 @@ public class ReflectionManager {
Location loc = entity.getLocation(); Location loc = entity.getLocation();
Object boundingBox = boundingBoxConstructor Object boundingBox = boundingBoxConstructor
.newInstance(loc.getX() - newBox.getX(), loc.getY() - newBox.getY(), loc.getZ() - newBox.getZ(), .newInstance(loc.getX() - (newBox.getX() / 2), loc.getY(), loc.getZ() - (newBox.getZ() / 2),
loc.getX() + newBox.getX(), loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ()); loc.getX() + (newBox.getX() / 2), loc.getY() + newBox.getY(),
loc.getZ() + (newBox.getZ() / 2));
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox); setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
} }