EntityPose.CROUCHING -> EntityPose.SNEAKING, fixes error in 1.14 and maintainability

This commit is contained in:
libraryaddict 2020-04-21 20:31:52 +12:00
parent 5d52f91f25
commit 822ad1b7fd
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
3 changed files with 6 additions and 4 deletions

View File

@ -9,6 +9,6 @@ public enum EntityPose {
SLEEPING, SLEEPING,
SWIMMING, SWIMMING,
SPIN_ATTACK, SPIN_ATTACK,
CROUCHING, SNEAKING,
DYING DYING
} }

View File

@ -663,7 +663,7 @@ public class FlagWatcher {
} else if (isSwimming()) { } else if (isSwimming()) {
setEntityPose(EntityPose.SWIMMING); setEntityPose(EntityPose.SWIMMING);
} else if (isSneaking()) { } else if (isSneaking()) {
setEntityPose(EntityPose.CROUCHING); setEntityPose(EntityPose.SNEAKING);
} else { } else {
setEntityPose(EntityPose.STANDING); setEntityPose(EntityPose.STANDING);
} }

View File

@ -1389,11 +1389,13 @@ public class ReflectionManager {
} }
public static Object getNmsEntityPose(EntityPose entityPose) { public static Object getNmsEntityPose(EntityPose entityPose) {
return Enum.valueOf(getNmsClass("EntityPose"), entityPose.name()); return Enum.valueOf(getNmsClass("EntityPose"),
entityPose == EntityPose.SNEAKING && NmsVersion.v1_15.isSupported() ? "CROUCHING" : entityPose.name());
} }
public static EntityPose getEntityPose(Object nmsEntityPose) { public static EntityPose getEntityPose(Object nmsEntityPose) {
return EntityPose.valueOf(((Enum) nmsEntityPose).name()); String name = ((Enum) nmsEntityPose).name();
return EntityPose.valueOf(name.equals("CROUCHING") ? "SNEAKING" : name);
} }
public static WrappedWatchableObject createWatchable(MetaIndex index, Object obj) { public static WrappedWatchableObject createWatchable(MetaIndex index, Object obj) {