Class ItemEntityPickupEvent.Pre

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent
net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent.Pre
Enclosing class:
ItemEntityPickupEvent

public static class ItemEntityPickupEvent.Pre extends ItemEntityPickupEvent
This event is fired when a player collides with an ItemEntity on the ground. It can be used to determine if the item may be picked up by the player.

If the pickup is successful (either by force or by default rules) ItemEntityPickupEvent.Post will be fired.

This event is only fired on the logical server.

  • Field Details

    • canPickup

      private net.minecraft.util.TriState canPickup
  • Constructor Details

    • Pre

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

    • setCanPickup

      public void setCanPickup(net.minecraft.util.TriState state)
      Changes if the player may pickup the item. Setting TriState.TRUE or TriState.FALSE will allow/deny the pickup respectively.

      The default rules require that ItemEntity.pickupDelay is zero, and that ItemEntity.target matches (or is null).

      Parameters:
      state - The new pickup state.
    • canPickup

      public net.minecraft.util.TriState canPickup()
      Returns the current pickup state.
      Returns:
      the current pickup state
      See Also: