diff --git a/pom.xml b/pom.xml index 1830302e0a..f48c787b11 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.retrooper packetevents - 1.6.1 + 1.6.2 diff --git a/src/main/java/io/github/retrooper/packetevents/packetwrappers/in/entityaction/WrappedPacketInEntityAction.java b/src/main/java/io/github/retrooper/packetevents/packetwrappers/in/entityaction/WrappedPacketInEntityAction.java index 29e4f39d02..d519627a34 100644 --- a/src/main/java/io/github/retrooper/packetevents/packetwrappers/in/entityaction/WrappedPacketInEntityAction.java +++ b/src/main/java/io/github/retrooper/packetevents/packetwrappers/in/entityaction/WrappedPacketInEntityAction.java @@ -15,6 +15,7 @@ public final class WrappedPacketInEntityAction extends WrappedPacket { private static final HashMap cachedPlayerActionNames = new HashMap(); + private static final HashMap cachedPlayerActionIDs = new HashMap(); private static Class entityActionClass; @Nullable private static Class enumPlayerActionClass; @@ -41,6 +42,15 @@ public static void load() { cachedPlayerActionNames.put("PRESS_SHIFT_KEY", PlayerAction.START_SNEAKING); cachedPlayerActionNames.put("RELEASE_SHIFT_KEY", PlayerAction.STOP_SNEAKING); cachedPlayerActionNames.put("RIDING_JUMP", PlayerAction.START_RIDING_JUMP); + + cachedPlayerActionIDs.put(1, PlayerAction.START_SNEAKING); + cachedPlayerActionIDs.put(2, PlayerAction.STOP_SNEAKING); + cachedPlayerActionIDs.put(3, PlayerAction.STOP_SLEEPING); + cachedPlayerActionIDs.put(4, PlayerAction.START_SPRINTING); + cachedPlayerActionIDs.put(5, PlayerAction.STOP_SPRINTING); + cachedPlayerActionIDs.put(6, PlayerAction.START_RIDING_JUMP); //riding jump + cachedPlayerActionIDs.put(7, PlayerAction.OPEN_INVENTORY); //horse interaction + } @Override @@ -54,11 +64,10 @@ protected void setup() { jumpBoost = Reflection.getField(entityActionClass, int.class, 1).getInt(packet); } - int animationIndex = -1; - //1.7.10 if (isLowerThan_v_1_8) { - animationIndex = Reflection.getField(entityActionClass, int.class, 1).getInt(packet); // TODO: += if packetdataserializer.version < 16 + int animationIndex = Reflection.getField(entityActionClass, int.class, 1).getInt(packet); // TODO: += if packetdataserializer.version < 16 + this.action = cachedPlayerActionIDs.get(animationIndex); } else { final Object enumObj = Reflection.getField(entityActionClass, enumPlayerActionClass, 0).get(packet); final String enumName = enumObj.toString(); @@ -68,9 +77,6 @@ protected void setup() { this.entityId = entityId; this.jumpBoost = jumpBoost; - if (animationIndex != -1) { - this.action = PlayerAction.values()[animationIndex]; - } } catch (IllegalAccessException e) { e.printStackTrace(); }