Set armor stands as markers on Minecraft 1.8

This commit is contained in:
filoghost 2018-08-20 18:27:04 +02:00
parent 49d6930389
commit a67866ff42
5 changed files with 25 additions and 1 deletions

View File

@ -31,6 +31,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
setArms(false);
setGravity(true);
setBasePlate(true);
try {
ReflectionUtils.callPrivateMethod(EntityArmorStand.class, this, "n", new Class[]{ boolean.class }, new Object[]{ true }); // n() = setMarker()
} catch (Exception e) {
e.printStackTrace();
// It will still work.
}
this.parentPiece = parentPiece;
try {
ReflectionUtils.setPrivateField(EntityArmorStand.class, this, "bg", Integer.MAX_VALUE);

View File

@ -31,6 +31,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
setArms(false);
setGravity(true);
setBasePlate(true);
try {
ReflectionUtils.callPrivateMethod(EntityArmorStand.class, this, "n", new Class[]{ boolean.class }, new Object[]{ true }); // n() = setMarker()
} catch (Exception e) {
e.printStackTrace();
// It will still work.
}
this.parentPiece = parentPiece;
try {
ReflectionUtils.setPrivateField(EntityArmorStand.class, this, "bi", Integer.MAX_VALUE);

View File

@ -31,6 +31,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
setArms(false);
setGravity(true);
setBasePlate(true);
try {
ReflectionUtils.callPrivateMethod(EntityArmorStand.class, this, "n", new Class[]{ boolean.class }, new Object[]{ true }); // n() = setMarker()
} catch (Exception e) {
e.printStackTrace();
// It will still work.
}
this.parentPiece = parentPiece;
try {
ReflectionUtils.setPrivateField(EntityArmorStand.class, this, "bi", Integer.MAX_VALUE);

View File

@ -12,7 +12,7 @@ public class Offsets {
WITHER_SKULL_WITH_SLIME = -0.22,
// For 1.8+, a single armor stand. As with wither skulls and horses, the bottom part of the nametag should be on the surface of the block.
ARMOR_STAND_ALONE = -1.25,
ARMOR_STAND_ALONE = -0.26,
// For 1.8+, an armor stand holding an item.
ARMOR_STAND_WITH_ITEM = -1.48,

View File

@ -29,6 +29,12 @@ public class ReflectionUtils {
return field.get(handle);
}
public static Object callPrivateMethod(Class<?> clazz, Object handle, String methodName, Class<?>[] parameterTypes, Object[] args) throws Exception {
Method method = clazz.getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
return method.invoke(handle, args);
}
private static Method getStackTraceElementMethod;
private static Method getStackTraceDepthMethod;