mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-11-05 09:09:40 +01:00
Fix bounding boxes
This commit is contained in:
parent
1c04576ae3
commit
dda362f082
@ -455,35 +455,37 @@ 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) {
|
||||||
if (isDisguiseInUse(disguise)) {
|
return;
|
||||||
DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
|
}
|
||||||
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
|
||||||
|
|
||||||
if (disguiseValues.getBabyBox() != null) {
|
if (isDisguiseInUse(disguise)) {
|
||||||
if ((disguise.getWatcher() instanceof AgeableWatcher &&
|
DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
|
||||||
((AgeableWatcher) disguise.getWatcher()).isBaby()) ||
|
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
||||||
(disguise.getWatcher() instanceof ZombieWatcher &&
|
|
||||||
((ZombieWatcher) disguise.getWatcher()).isBaby())) {
|
if (disguiseValues.getBabyBox() != null) {
|
||||||
disguiseBox = disguiseValues.getBabyBox();
|
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;
|
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")) {
|
||||||
stage++;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (stage) {
|
stage++;
|
||||||
case 1:
|
|
||||||
x -= field.getDouble(boundingBox);
|
switch (stage) {
|
||||||
break;
|
case 1:
|
||||||
case 2:
|
x -= field.getDouble(boundingBox);
|
||||||
y -= field.getDouble(boundingBox);
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 3:
|
y -= field.getDouble(boundingBox);
|
||||||
z -= field.getDouble(boundingBox);
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 4:
|
z -= field.getDouble(boundingBox);
|
||||||
x += field.getDouble(boundingBox);
|
break;
|
||||||
break;
|
case 4:
|
||||||
case 5:
|
x += field.getDouble(boundingBox);
|
||||||
y += field.getDouble(boundingBox);
|
break;
|
||||||
break;
|
case 5:
|
||||||
case 6:
|
y += field.getDouble(boundingBox);
|
||||||
z += field.getDouble(boundingBox);
|
break;
|
||||||
break;
|
case 6:
|
||||||
default:
|
z += field.getDouble(boundingBox);
|
||||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
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();
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user