Fix bounding boxes
This commit is contained in:
		| @@ -455,35 +455,37 @@ public class DisguiseUtilities { | ||||
|     public static void doBoundingBox(TargetedDisguise disguise) { | ||||
|         Entity entity = disguise.getEntity(); | ||||
|  | ||||
|         if (entity != null) { | ||||
|             if (isDisguiseInUse(disguise)) { | ||||
|                 DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType()); | ||||
|                 FakeBoundingBox disguiseBox = disguiseValues.getAdultBox(); | ||||
|         if (entity == null) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|                 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)) { | ||||
|             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); | ||||
|             } else { | ||||
|                 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); | ||||
|             } | ||||
|  | ||||
|             ReflectionManager.setBoundingBox(entity, disguiseBox); | ||||
|         } else { | ||||
|             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); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -187,31 +187,33 @@ public class ReflectionManager { | ||||
|             int stage = 0; | ||||
|  | ||||
|             for (Field field : boundingBox.getClass().getDeclaredFields()) { | ||||
|                 if (field.getType().getSimpleName().equals("double")) { | ||||
|                     stage++; | ||||
|                 if (!field.getType().getSimpleName().equals("double")) { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                     switch (stage) { | ||||
|                         case 1: | ||||
|                             x -= field.getDouble(boundingBox); | ||||
|                             break; | ||||
|                         case 2: | ||||
|                             y -= field.getDouble(boundingBox); | ||||
|                             break; | ||||
|                         case 3: | ||||
|                             z -= field.getDouble(boundingBox); | ||||
|                             break; | ||||
|                         case 4: | ||||
|                             x += field.getDouble(boundingBox); | ||||
|                             break; | ||||
|                         case 5: | ||||
|                             y += field.getDouble(boundingBox); | ||||
|                             break; | ||||
|                         case 6: | ||||
|                             z += field.getDouble(boundingBox); | ||||
|                             break; | ||||
|                         default: | ||||
|                             throw new Exception("Error while setting the bounding box, more doubles than I thought??"); | ||||
|                     } | ||||
|                 stage++; | ||||
|  | ||||
|                 switch (stage) { | ||||
|                     case 1: | ||||
|                         x -= field.getDouble(boundingBox); | ||||
|                         break; | ||||
|                     case 2: | ||||
|                         y -= field.getDouble(boundingBox); | ||||
|                         break; | ||||
|                     case 3: | ||||
|                         z -= field.getDouble(boundingBox); | ||||
|                         break; | ||||
|                     case 4: | ||||
|                         x += field.getDouble(boundingBox); | ||||
|                         break; | ||||
|                     case 5: | ||||
|                         y += field.getDouble(boundingBox); | ||||
|                         break; | ||||
|                     case 6: | ||||
|                         z += field.getDouble(boundingBox); | ||||
|                         break; | ||||
|                     default: | ||||
|                         throw new Exception("Error while setting the bounding box, more doubles than I thought??"); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @@ -618,8 +620,9 @@ public class ReflectionManager { | ||||
|             Location loc = entity.getLocation(); | ||||
|  | ||||
|             Object boundingBox = boundingBoxConstructor | ||||
|                     .newInstance(loc.getX() - newBox.getX(), loc.getY() - newBox.getY(), loc.getZ() - newBox.getZ(), | ||||
|                             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() / 2), loc.getY() + newBox.getY(), | ||||
|                             loc.getZ() + (newBox.getZ() / 2)); | ||||
|  | ||||
|             setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user