Fix bounding boxes having incorrect Y (or am I now breaking it)

This commit is contained in:
libraryaddict 2024-11-24 19:19:28 +13:00
parent 1739ef51c0
commit fedde0d3f4
14 changed files with 20 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<DisguiseType, DisguiseValues> 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;
}

View File

@ -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;