Interface Item

All Superinterfaces:
Audience, CommandSender, DataComponentView, Entity, Frictional, HoverEventSource<HoverEvent.ShowEntity>, Metadatable, Nameable, Permissible, PersistentDataHolder, PersistentDataViewHolder, Pointered, ServerOperator, Sound.Emitter

public interface Item extends Entity, Frictional
Represents a dropped item.
Since:
1.0.0
  • Method Details

    • getItemStack

      @NotNull @NotNull ItemStack getItemStack()
      Gets the item stack associated with this item drop.
      Returns:
      An item stack.
      Since:
      1.0.0
    • setItemStack

      void setItemStack(@NotNull @NotNull ItemStack stack)
      Sets the item stack associated with this item drop.
      Parameters:
      stack - An item stack.
      Since:
      1.0.0
    • getPickupDelay

      int getPickupDelay()
      Gets the delay before this Item is available to be picked up by players
      Returns:
      Remaining delay
      Since:
      1.0.0
    • setPickupDelay

      void setPickupDelay(int delay)
      Sets the delay before this Item is available to be picked up by players
      Parameters:
      delay - New delay
      Since:
      1.0.0
    • setUnlimitedLifetime

      void setUnlimitedLifetime(boolean unlimited)
      Sets if this Item should live forever
      Parameters:
      unlimited - true if the lifetime is unlimited
      Since:
      1.18.2
    • isUnlimitedLifetime

      boolean isUnlimitedLifetime()
      Gets if this Item lives forever
      Returns:
      true if the lifetime is unlimited
      Since:
      1.18.2
    • setOwner

      void setOwner(@Nullable @Nullable UUID owner)
      Sets the owner of this item. Other entities will not be able to pickup this item when an owner is set.
      Parameters:
      owner - UUID of new owner
      Since:
      1.13.1
    • getOwner

      Get the owner of this item.
      Returns:
      UUID of owner
      Since:
      1.13.1
    • setThrower

      void setThrower(@Nullable @Nullable UUID uuid)
      Set the thrower of this item. The thrower is the entity which dropped the item. This affects the trigger criteria for item pickups, for things such as advancements.
      Parameters:
      uuid - UUID of thrower
      Since:
      1.13.1
    • getThrower

      @Nullable @Nullable UUID getThrower()
      Get the thrower of this item. The thrower is the entity which dropped the item.
      Returns:
      UUID of thrower
      Since:
      1.13.1
    • canMobPickup

      boolean canMobPickup()
      Gets if non-player entities can pick this Item up
      Returns:
      True if non-player entities can pickup
      Since:
      1.12
    • setCanMobPickup

      void setCanMobPickup(boolean canMobPickup)
      Sets if non-player entities can pick this Item up
      Parameters:
      canMobPickup - True to allow non-player entity pickup
      Since:
      1.12
    • canPlayerPickup

      boolean canPlayerPickup()
      Gets whether the player can pickup the item or not
      Returns:
      True if a player can pickup the item
      Since:
      1.16.4
    • setCanPlayerPickup

      void setCanPlayerPickup(boolean canPlayerPickup)
      Sets whether the item can be picked up or not. Modifies the pickup delay value to do so.
      Parameters:
      canPlayerPickup - True if the player can pickup the item
      Since:
      1.16.4
    • willAge

      boolean willAge()
      Gets whether the item will age and despawn from being on the ground too long
      Returns:
      True if the item will age
      Since:
      1.16.4
    • setWillAge

      void setWillAge(boolean willAge)
      Sets whether the item will age or not. If the item is not ageing, it will not despawn by being on the ground for too long.
      Parameters:
      willAge - True if the item should age
      Since:
      1.16.4
    • getHealth

      int getHealth()
      Gets the health of item stack.

      Currently the default max health is 5.

      Returns:
      the health
      Since:
      1.18.1
    • setHealth

      void setHealth(int health)
      Sets the health of the item stack. If the value is non-positive the itemstack's normal "on destroy" functionality will be run.

      Currently, the default max health is 5.

      Parameters:
      health - the health, a non-positive value will destroy the entity
      Since:
      1.18.1