Class ItemEntityPickupEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent
Direct Known Subclasses:
ItemEntityPickupEvent.Post, ItemEntityPickupEvent.Pre

public abstract class ItemEntityPickupEvent extends net.neoforged.bus.api.Event
Parent class of the two events that fire when a Player collides with an ItemEntity.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This event is fired when an ItemEntity on the ground has been picked up by the player and after the item is added to the player's inventory.
    static class 
    This event is fired when a player collides with an ItemEntity on the ground.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final net.minecraft.world.entity.item.ItemEntity
     
    private final net.minecraft.world.entity.player.Player
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemEntityPickupEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.item.ItemEntity item)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.entity.item.ItemEntity
    Returns the ItemEntity that was collided with.
    net.minecraft.world.entity.player.Player
    Returns the player who collided with the item.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • player

      private final net.minecraft.world.entity.player.Player player
    • item

      private final net.minecraft.world.entity.item.ItemEntity item
  • Constructor Details

    • ItemEntityPickupEvent

      public ItemEntityPickupEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.item.ItemEntity item)
  • Method Details

    • getPlayer

      public net.minecraft.world.entity.player.Player getPlayer()
      Returns the player who collided with the item.
      Returns:
      the player who collided with the item
    • getItemEntity

      public net.minecraft.world.entity.item.ItemEntity getItemEntity()
      Returns the ItemEntity that was collided with.

      Changes to this item entity will impact further processing by the game and other event handlers.

      Modification of the stored stack ItemEntity.getItem() is legal, but consumers of this event must not call ItemEntity.setItem(ItemStack), as it will incur undefined behavior.