ProtocolLib

3M Downloads

[1.16.5] How to get action in Use Entity listener

abcdef-007 opened this issue · 3 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

I'm creating a plugin which supports 1.16.5 so I'm using 5.2.0 on my plugin build file and on the server. My problem is that I get an error: java.lang.NoClassDefFoundError: Could not initialize class com.comphenix.protocol.wrappers.WrappedEnumEntityUseAction. This is my code:

public class EntityUseListener extends PacketAdapter {
    public UseEntityListener(Plugin plugin, ListenerPriority priority) {
        super(plugin, priority, PacketType.Play.Client.USE_ENTITY);
    }

    @Override
    public void onPacketReceiving(PacketEvent event) {
        // ERROR IN THE LINE BELOW
        final WrappedEnumEntityUseAction wrappedAction = event.getPacket().getEnumEntityUseActions().read(0);
        final EnumWrappers.EntityUseAction action = wrappedAction.getAction();
        // ...
    }
}

How can I fix it?

commented

yes, it changed exactly in version 1.17

commented

Use getEntityUseActions instead of getEnumEntityUseActions. The wrapper accessor (returned by getEnumEntityUseActions) is only needed when running on 1.17 or newer.

commented

Use getEntityUseActions instead of getEnumEntityUseActions. The wrapper accessor (returned by getEnumEntityUseActions) is only needed when running on 1.17 or newer.

Thank you, I didn't know that. When did it change? In 1.17 exactly or 1.17.1?