Skip to content

Cancelling EntityPickupItemEvent doesn't remove items from Villagers #6068

@OmerBenGera

Description

@OmerBenGera

Expected behavior

When cancelling the EntityPickupItemEvent, villagers should not pick up the item.

Observed/Actual behavior

It works well when they pickup a new item, however if the item they pickup is modifying another item in the inventory (for example, they have 1 bread and they pick another one), the item is still added (or in other words, the modified item is not reverted as well)

Steps/models to reproduce

Get a villager with 1 bread in the inventory, drop another bread and check the inventory.
Here is an image of the inventory when the villager tries to pick up a new item:
https://gyazo.com/e1e322a55ae27ff8add97c6e0b54365b

The first line is before the villager tried to pickup the item, the other lines are a few times after he tried to pick it up. He can't pick up more items when the item in the inventory is 64 items.

Plugin list

A plugin that stops the villagers from picking up items (custom coded, code is shown below)

Paper version

This server is running Paper version git-Paper-779 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
You are running the latest version
Previous version: git-Paper-674 (MC: 1.16.5)

Agreements

  • I am running the latest version of Paper available from https://papermc.io/downloads.
  • I have searched for and ensured there isn't already an open issue regarding this.
  • My version of Minecraft is supported by Paper.

Other

Cancel pickup event:

    @EventHandler
    public void onEntityPickup(EntityPickupItemEvent e){
        if(e.getEntityType() == EntityType.VILLAGER)
            e.setCancelled(true);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.version: 1.16Game version 1.16version: 1.17Game version 1.17

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions