Skip to content

Commit

Permalink
1.6.2 release
Browse files Browse the repository at this point in the history
* Issues with WrappedPacketInEntityAction on 1.7.10
  • Loading branch information
Retrooper committed Aug 30, 2020
1 parent 427a0ff commit d5454b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>

<!-- You can build the project with this: "mvn clean compile assembly:single" -->
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

public final class WrappedPacketInEntityAction extends WrappedPacket {
private static final HashMap<String, PlayerAction> cachedPlayerActionNames = new HashMap<String, PlayerAction>();
private static final HashMap<Integer, PlayerAction> cachedPlayerActionIDs = new HashMap<Integer, PlayerAction>();
private static Class<?> entityActionClass;
@Nullable
private static Class<?> enumPlayerActionClass;
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit d5454b9

Please sign in to comment.