Skip to content

LEFT_CLICK actions don't fire on Minecraft 26.1+ (right-click works fine) #230

Description

@mjiangmc

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions