Environment
- Plugin version: 2.1.0 (
2.X branch, commit 705962d)
- Server: Minecraft 26.2
- packetevents: 2.13.0
Steps to reproduce
/znpc action add consolecommand test LEFT_CLICK 1 0 minecraft:tell %player_name% test
Left-click the NPC → nothing happens. Right-click the same NPC → works as expected.
Root cause
Starting in Minecraft 26.1, Mojang split "attack / left-click" out of ServerboundInteractPacket (INTERACT_ENTITY) into a new dedicated ServerboundAttackPacket:
- Right-click still goes through
INTERACT_ENTITY (action = INTERACT / INTERACT_AT)
- Left-click now goes through the new
ATTACK packet (PacketType.Play.Client.ATTACK / WrapperPlayClientAttack in packetevents)
However, InteractionPacketListener only listens for INTERACT_ENTITY:
if (event.getPacketType() != PacketType.Play.Client.INTERACT_ENTITY) return;
So on 26.1+, the ATTACK packet sent on left-click is silently ignored, and LEFT_CLICK actions never fire.
This is confirmed by the packetevents source:
WrapperPlayClientInteractEntity javadoc: "…or attacks an entity (for versions older than 26.1)"
- On 26.1+ its
read() hardcodes action to INTERACT_AT as a compatibility value — the attack action is no longer part of that packet.
Proposed fix
Handle the ATTACK packet in InteractionPacketListener.onPacketReceive and map it to LEFT_CLICK:
InteractionType type;
int entityId;
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) {
WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event);
entityId = packet.getEntityId();
type = wrapClickType(packet.getAction());
} else if (event.getPacketType() == PacketType.Play.Client.ATTACK) {
entityId = new WrapperPlayClientAttack(event).getEntityId();
type = InteractionType.LEFT_CLICK;
} else {
return;
}
The rest of the logic (cooldown, NpcInteractEvent, action filtering) is unchanged. The allay workaround condition is equivalently rewritten from action == INTERACT/INTERACT_AT to type == RIGHT_CLICK.
Environment
2.Xbranch, commit705962d)Steps to reproduce
Left-click the NPC → nothing happens. Right-click the same NPC → works as expected.
Root cause
Starting in Minecraft 26.1, Mojang split "attack / left-click" out of
ServerboundInteractPacket(INTERACT_ENTITY) into a new dedicatedServerboundAttackPacket:INTERACT_ENTITY(action =INTERACT/INTERACT_AT)ATTACKpacket (PacketType.Play.Client.ATTACK/WrapperPlayClientAttackin packetevents)However,
InteractionPacketListeneronly listens forINTERACT_ENTITY:So on 26.1+, the
ATTACKpacket sent on left-click is silently ignored, andLEFT_CLICKactions never fire.This is confirmed by the packetevents source:
WrapperPlayClientInteractEntityjavadoc: "…or attacks an entity (for versions older than 26.1)"read()hardcodesactiontoINTERACT_ATas a compatibility value — the attack action is no longer part of that packet.Proposed fix
Handle the
ATTACKpacket inInteractionPacketListener.onPacketReceiveand map it toLEFT_CLICK:The rest of the logic (cooldown,
NpcInteractEvent, action filtering) is unchanged. The allay workaround condition is equivalently rewritten fromaction == INTERACT/INTERACT_ATtotype == RIGHT_CLICK.