ProtocolLib

3M Downloads

1.17 get type of PacketPlayInUseEntity

Photon-GitHub opened this issue ยท 5 comments

commented

Make sure you're doing the following

  • You're using the latest build for your server version
  • This isn't an issue caused by another plugin
  • You've checked for duplicate issues
  • You didn't use /reload

Describe the question
In PacketPlayInUseEntity I was able to get the action type enum by using handle.getEntityUseActions().read(0);
On 1.17 this throws a FieldAccessException: No field with type net.minecraft.network.protocol.game.PacketPlayInUseEntity$b exists in class PacketPlayInUseEntity.

Given that according to https://wiki.vg/Protocol#Interact_Entity there should still be the enum in 1.17, I would like to know whether this is a bug or I need to use a different method.

API method(s) used
handle.getEntityUseActions().read(0);

Expected behavior
Return the enum as it does on versions prior to 1.17

Code
handle.getEntityUseActions().read(0);

commented

I was able to fix the issue by using

handle.getEnumEntityUseActions().read(0).getAction();

I am not sure if that breaking change was intentional but maybe you could make the old version return that for backwards compatibility?

commented

The fix below does work, running into getHands() is not working correctly on this packet, the data is there in the structured modified.

packet.getHands().read(0)

commented

Looks like the enum entity use actions are slightly different; interact has a hand field and interact_at has both a hand and position. I could add backwards compatibility pretty easily, but it might lead to some weird behavior.

commented

Mmm, backward compatibility there would be simple because the hand is still available in the same packets as last time, weird how the wiki missed this change. Both packets on the wiki between 1.16 and 1.17 are identicle.

commented

it's possible it's not sent; i know the wiki bases it off of the data that's actually serialized