1.15.2 EntityPickupItemEvent change amount

Discussion in 'Spigot Plugin Development' started by Endothelium, Jan 26, 2020.

  1. Hello,
    I am new to minecraft development and this may be a really stupid question, so sorry.

    I am working with the EntityPickupItemEvent, and i'm trying to do something simple, change the amount of items that are looted. Here is the code :

    Code (Java):

        @EventHandler(priority = EventPriority.LOWEST)
        public void onEntityPickup(EntityPickupItemEvent event){
            // here we set itemstack amout to 1
    So the example may be stupid, and it is, but i don't need more for my question. With the previous code, i still loot the initial amount that was on the floor, and not 1.

    So i have a solution for this : managing the inventory manually and cancel the event, then remove the item on the floor with event.getItem().remove(), then using minecraft packet to still have the sucking animation of the item, but is there a simpler solution?