Fix the bounding box problems. Now just block glitching and suffocation
This commit is contained in:
parent
f6d0994079
commit
d00d10f3a8
@ -136,28 +136,26 @@ public class DisguiseUtilities {
|
|||||||
// TODO Slimes
|
// TODO Slimes
|
||||||
Entity entity = disguise.getEntity();
|
Entity entity = disguise.getEntity();
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (isDisguiseInUse(disguise)) {
|
DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
|
||||||
DisguiseValues values = DisguiseValues.getDisguiseValues(disguise.getType());
|
DisguiseValues entityValues = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
|
||||||
FakeBoundingBox fakeBox = values.getAdultBox();
|
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
||||||
if (values.getBabyBox() != null) {
|
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
||||||
if (disguise.getWatcher() instanceof AgeableWatcher
|
if (entityValues.getBabyBox() != null) {
|
||||||
&& (((AgeableWatcher) disguise.getWatcher()).isBaby())
|
|
||||||
|| (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher())
|
|
||||||
.isBaby())) {
|
|
||||||
fakeBox = values.getBabyBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ReflectionManager.setBoundingBox(entity, fakeBox.getX(), fakeBox.getY(), fakeBox.getZ());
|
|
||||||
} else {
|
|
||||||
DisguiseValues values = DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
|
|
||||||
FakeBoundingBox fakeBox = values.getAdultBox();
|
|
||||||
if (values.getBabyBox() != null) {
|
|
||||||
if (entity instanceof Ageable && !(((Ageable) entity).isAdult())
|
if (entity instanceof Ageable && !(((Ageable) entity).isAdult())
|
||||||
|| (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
|| (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
||||||
fakeBox = values.getBabyBox();
|
entityBox = entityValues.getBabyBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReflectionManager.setBoundingBox(disguise.getEntity(), fakeBox.getX(), fakeBox.getY(), fakeBox.getZ());
|
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)) {
|
||||||
|
ReflectionManager.setBoundingBox(entity, entityBox, disguiseBox);
|
||||||
|
} else {
|
||||||
|
ReflectionManager.setBoundingBox(entity, disguiseBox, entityBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class ReflectionManager {
|
|||||||
double x = 0, y = 0, z = 0;
|
double x = 0, y = 0, z = 0;
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
for (Field field : boundingBox.getClass().getFields()) {
|
for (Field field : boundingBox.getClass().getFields()) {
|
||||||
if (field.getType().getSimpleName().equals("Double")) {
|
if (field.getType().getSimpleName().equals("double")) {
|
||||||
stage++;
|
stage++;
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -114,9 +114,9 @@ public class ReflectionManager {
|
|||||||
default:
|
default:
|
||||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return new FakeBoundingBox(x, y, z);
|
return new FakeBoundingBox(x, y, z);
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -235,32 +235,26 @@ public class ReflectionManager {
|
|||||||
return after17;
|
return after17;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBoundingBox(Entity entity, double newX, double newY, double newZ) {
|
public static void setBoundingBox(Entity entity, FakeBoundingBox oldBox, FakeBoundingBox newBox) {
|
||||||
try {
|
try {
|
||||||
Object boundingBox = getNmsClass("Entity").getField("boundingBox").get(getNmsEntity(entity));
|
Object boundingBox = getNmsClass("Entity").getField("boundingBox").get(getNmsEntity(entity));
|
||||||
double x = 0, y = 0, z = 0;
|
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
for (Field field : boundingBox.getClass().getFields()) {
|
for (Field field : boundingBox.getClass().getFields()) {
|
||||||
if (field.getType().getSimpleName().equals("Double")) {
|
if (field.getType().getSimpleName().equals("double")) {
|
||||||
stage++;
|
stage++;
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case 1:
|
case 1:
|
||||||
x = field.getDouble(boundingBox);
|
field.setDouble(boundingBox, field.getDouble(boundingBox) + (oldBox.getX() - newBox.getX()));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
y = field.getDouble(boundingBox);
|
field.setDouble(boundingBox, field.getDouble(boundingBox) + (oldBox.getY() - newBox.getY()));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
z = field.getDouble(boundingBox);
|
field.setDouble(boundingBox, field.getDouble(boundingBox) + (oldBox.getZ() - newBox.getZ()));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
field.setDouble(boundingBox, x);
|
|
||||||
break;
|
|
||||||
case 5:
|
case 5:
|
||||||
field.setDouble(boundingBox, y);
|
|
||||||
break;
|
|
||||||
case 6:
|
case 6:
|
||||||
field.setDouble(boundingBox, z);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||||
|
Loading…
Reference in New Issue
Block a user