[SPIGOT-6093] Can't change ItemStack in EntityPickupItemEvent Created: 20/Aug/20  Updated: 21/Aug/20  Resolved: 21/Aug/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Shane Bee Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Attachments: File TesterPlugin-1.0.0.jar    
Version: git-Spigot-379750e-eaf0bac
Guidelines Read: Yes

 Description   

I noticed when fiddling around with some code, that the ItemStack can't be changed in an ItemPickupEvent.

Test code:

@EventHandler
private void onDrop(EntityPickupItemEvent event) {
    Item item = event.getItem();
    item.setItemStack(new ItemStack(Material.DIAMOND));
}

When this is fired, nothing happens.
Digging thru the code where this event is called, I noticed there's a local field for ItemStack. At the beginning of the pickup method, the field is set and never updated after the events.

Including a tester plugin if you wish to test.
All you need to do is drop any item, and attempt to pick it up, it SHOULD be changed to a DIAMOND but it is not.

I'm going to work on a PR that can fix this issue.



 Comments   
Comment by Shane Bee [ 20/Aug/20 ]

(in my mind I uploaded the plugin, but clearly didn't)

 

PR Submitted: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/732/overview

Generated at Sat Dec 13 20:50:05 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.