Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6093

Can't change ItemStack in EntityPickupItemEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • git-Spigot-379750e-eaf0bac
    • Yes

      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.

            Unassigned Unassigned
            ShaneBee Shane Bee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: