From fedde0d3f4c9c35a57b557a419ca52c0ca8d77ce Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 24 Nov 2024 19:19:28 +1300 Subject: [PATCH] Fix bounding boxes having incorrect Y (or am I now breaking it) --- .../utilities/reflection/v1_17/ReflectionManager.java | 3 +-- .../reflection/v1_18_1/ReflectionManager.java | 3 +-- .../reflection/v1_18_2/ReflectionManager.java | 3 +-- .../reflection/v1_19_R1/ReflectionManager.java | 3 +-- .../reflection/v1_19_R2/ReflectionManager.java | 3 +-- .../reflection/v1_19_R3/ReflectionManager.java | 3 +-- .../reflection/v1_20_R1/ReflectionManager.java | 3 +-- .../reflection/v1_20_R2/ReflectionManager.java | 3 +-- .../reflection/v1_20_R3/ReflectionManager.java | 3 +-- .../reflection/v1_20_R4/ReflectionManager.java | 3 +-- .../reflection/v1_21_R1/ReflectionManager.java | 3 +-- .../reflection/v1_21_R2/ReflectionManager.java | 3 +-- .../disguise/utilities/DisguiseValues.java | 10 ++-------- .../utilities/reflection/ReflectionManager.java | 6 ++++++ 14 files changed, 20 insertions(+), 32 deletions(-) diff --git a/nms/v1_17_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_17/ReflectionManager.java b/nms/v1_17_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_17/ReflectionManager.java index 0c11a912..4e6effb7 100644 --- a/nms/v1_17_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_17/ReflectionManager.java +++ b/nms/v1_17_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_17/ReflectionManager.java @@ -253,8 +253,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_18_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_1/ReflectionManager.java b/nms/v1_18_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_1/ReflectionManager.java index 153ee4fe..7dbf977f 100644 --- a/nms/v1_18_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_1/ReflectionManager.java +++ b/nms/v1_18_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_1/ReflectionManager.java @@ -253,8 +253,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_18_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_2/ReflectionManager.java b/nms/v1_18_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_2/ReflectionManager.java index 22a9d261..4e4fd74b 100644 --- a/nms/v1_18_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_2/ReflectionManager.java +++ b/nms/v1_18_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_18_2/ReflectionManager.java @@ -255,8 +255,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R1/ReflectionManager.java b/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R1/ReflectionManager.java index 1bfe40fe..0902ed59 100644 --- a/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R1/ReflectionManager.java +++ b/nms/v1_19_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R1/ReflectionManager.java @@ -254,8 +254,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_19_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R2/ReflectionManager.java b/nms/v1_19_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R2/ReflectionManager.java index 0028132b..718cf4ce 100644 --- a/nms/v1_19_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R2/ReflectionManager.java +++ b/nms/v1_19_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R2/ReflectionManager.java @@ -273,8 +273,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_19_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R3/ReflectionManager.java b/nms/v1_19_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R3/ReflectionManager.java index 6b586227..4d67ae48 100644 --- a/nms/v1_19_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R3/ReflectionManager.java +++ b/nms/v1_19_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_19_R3/ReflectionManager.java @@ -268,8 +268,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_20_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R1/ReflectionManager.java b/nms/v1_20_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R1/ReflectionManager.java index e0cefede..1e30ffe3 100644 --- a/nms/v1_20_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R1/ReflectionManager.java +++ b/nms/v1_20_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R1/ReflectionManager.java @@ -269,8 +269,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_20_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R2/ReflectionManager.java b/nms/v1_20_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R2/ReflectionManager.java index 9599064a..7f9c1341 100644 --- a/nms/v1_20_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R2/ReflectionManager.java +++ b/nms/v1_20_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R2/ReflectionManager.java @@ -282,8 +282,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_20_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R3/ReflectionManager.java b/nms/v1_20_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R3/ReflectionManager.java index f466e3f8..c8cd5617 100644 --- a/nms/v1_20_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R3/ReflectionManager.java +++ b/nms/v1_20_R3/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R3/ReflectionManager.java @@ -283,8 +283,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_20_R4/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R4/ReflectionManager.java b/nms/v1_20_R4/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R4/ReflectionManager.java index 342597a0..408957c8 100644 --- a/nms/v1_20_R4/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R4/ReflectionManager.java +++ b/nms/v1_20_R4/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_20_R4/ReflectionManager.java @@ -286,8 +286,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_21_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R1/ReflectionManager.java b/nms/v1_21_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R1/ReflectionManager.java index 1357cd83..ebe335f3 100644 --- a/nms/v1_21_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R1/ReflectionManager.java +++ b/nms/v1_21_R1/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R1/ReflectionManager.java @@ -291,8 +291,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/nms/v1_21_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R2/ReflectionManager.java b/nms/v1_21_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R2/ReflectionManager.java index 38a3ed6d..fa3e78da 100644 --- a/nms/v1_21_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R2/ReflectionManager.java +++ b/nms/v1_21_R2/src/main/java/me/libraryaddict/disguise/utilities/reflection/v1_21_R2/ReflectionManager.java @@ -293,8 +293,7 @@ public class ReflectionManager implements ReflectionManagerAbstract { public void setBoundingBox(Entity entity, double x, double y, double z) { Location loc = entity.getLocation(); ((CraftEntity) entity).getHandle().setBoundingBox( - new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, - loc.getZ() + z / 2)); + new AABB(loc.getX() - x / 2, loc.getY(), loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y, loc.getZ() + z / 2)); } @Override diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java index 6021894b..4851cbbc 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseValues.java @@ -1,10 +1,12 @@ package me.libraryaddict.disguise.utilities; +import lombok.Setter; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox; import java.util.HashMap; +@Setter public class DisguiseValues { private static final HashMap values = new HashMap<>(); @@ -25,18 +27,10 @@ public class DisguiseValues { return adultBox; } - public void setAdultBox(FakeBoundingBox newBox) { - adultBox = newBox; - } - public FakeBoundingBox getBabyBox() { return babyBox; } - public void setBabyBox(FakeBoundingBox newBox) { - babyBox = newBox; - } - public double getMaxHealth() { return maxHealth; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java index 6749e23a..311aa151 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java @@ -1382,6 +1382,12 @@ public class ReflectionManager { double y = newBox.getY(); double z = newBox.getZ(); + if (NmsVersion.v1_20_R4.isSupported()) { + x *= scale; + y *= scale; + z *= scale; + } + if (nmsReflection != null) { nmsReflection.setBoundingBox(entity, x, y, z); return;