mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-12 15:07:22 +01:00
Do bounding box to scale too (not tested)
This commit is contained in:
parent
aebca5ad40
commit
c48a20eb01
@ -1323,7 +1323,19 @@ public class DisguiseUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
ReflectionManager.setBoundingBox(entity, disguiseBox);
|
||||
double scale = 1;
|
||||
|
||||
if (NmsVersion.v1_20_R4.isSupported() && disguise.getWatcher() instanceof LivingWatcher) {
|
||||
Double disguiseScale = ((LivingWatcher) disguise.getWatcher()).getScale();
|
||||
|
||||
if (disguiseScale != null) {
|
||||
scale = disguiseScale;
|
||||
} else {
|
||||
scale = DisguiseUtilities.getEntityScaleWithoutLibsDisguises(disguise.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
ReflectionManager.setBoundingBox(entity, disguiseBox, scale);
|
||||
} else {
|
||||
DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
|
||||
|
||||
@ -1336,7 +1348,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
ReflectionManager.setBoundingBox(entity, entityBox);
|
||||
ReflectionManager.setBoundingBox(entity, entityBox, DisguiseUtilities.getEntityScaleWithoutLibsDisguises(disguise.getEntity()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3514,7 +3526,7 @@ public class DisguiseUtilities {
|
||||
* Grabs the scale of the entity as if the LibsDisguises: attributes did not exist
|
||||
*/
|
||||
public static double getEntityScaleWithoutLibsDisguises(Entity entity) {
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
if (!NmsVersion.v1_20_R4.isSupported() || !(entity instanceof LivingEntity)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1373,9 +1373,13 @@ public class ReflectionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) {
|
||||
public static void setBoundingBox(Entity entity, FakeBoundingBox newBox, double scale) {
|
||||
double x = newBox.getX();
|
||||
double y = newBox.getY();
|
||||
double z = newBox.getZ();
|
||||
|
||||
if (nmsReflection != null) {
|
||||
nmsReflection.setBoundingBox(entity, newBox.getX(), newBox.getY(), newBox.getZ());
|
||||
nmsReflection.setBoundingBox(entity, x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1383,8 +1387,8 @@ public class ReflectionManager {
|
||||
Location loc = entity.getLocation();
|
||||
|
||||
Object boundingBox =
|
||||
boundingBoxConstructor.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));
|
||||
boundingBoxConstructor.newInstance(loc.getX() - (x / 2), loc.getY(), loc.getZ() - (z / 2), loc.getX() + (x / 2),
|
||||
loc.getY() + y, loc.getZ() + (z / 2));
|
||||
|
||||
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
|
||||
} catch (Exception ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user