Class ItemEntity

java.lang.Object
net.minecraft.entity.Entity
net.minecraft.entity.ItemEntity
All Implemented Interfaces:
CommandOutput, Nameable

public class ItemEntity
extends Entity
  • Field Details

    • STACK

      private static final TrackedData<ItemStack> STACK
    • itemAge

      private int itemAge
      The number of ticks since this item entity has been created. It is a short value with key Age in the NBT structure.

      It differs from Entity.age.

    • pickupDelay

      private int pickupDelay
    • health

      private int health
    • thrower

      private UUID thrower
    • owner

      private UUID owner
    • uniqueOffset

      public final float uniqueOffset
  • Constructor Details

    • ItemEntity

      public ItemEntity​(EntityType<? extends ItemEntity> type, World world)
    • ItemEntity

      public ItemEntity​(World world, double x, double y, double z)
    • ItemEntity

      public ItemEntity​(World world, double x, double y, double z, ItemStack stack)
    • ItemEntity

      @Environment(CLIENT) private ItemEntity​(ItemEntity itemEntity)
  • Method Details

    • canClimb

      protected boolean canClimb()
      Overrides:
      canClimb in class Entity
    • initDataTracker

      protected void initDataTracker()
      Specified by:
      initDataTracker in class Entity
    • tick

      public void tick()
      Overrides:
      tick in class Entity
    • applyWaterBuoyancy

      private void applyWaterBuoyancy()
    • method_24348

      private void method_24348()
    • tryMerge

      private void tryMerge()
    • canMerge

      private boolean canMerge()
    • tryMerge

      private void tryMerge​(ItemEntity other)
    • canMerge

      public static boolean canMerge​(ItemStack stack1, ItemStack stack2)
    • merge

      public static ItemStack merge​(ItemStack stack1, ItemStack stack2, int maxCount)
    • merge

      private static void merge​(ItemEntity targetEntity, ItemStack stack1, ItemStack stack2)
    • merge

      private static void merge​(ItemEntity targetEntity, ItemStack targetStack, ItemEntity sourceEntity, ItemStack sourceStack)
    • isFireImmune

      public boolean isFireImmune()
      Overrides:
      isFireImmune in class Entity
    • damage

      public boolean damage​(DamageSource source, float amount)
      Overrides:
      damage in class Entity
    • writeCustomDataToNbt

      public void writeCustomDataToNbt​(NbtCompound nbt)
      Specified by:
      writeCustomDataToNbt in class Entity
    • readCustomDataFromNbt

      public void readCustomDataFromNbt​(NbtCompound nbt)
      Specified by:
      readCustomDataFromNbt in class Entity
    • onPlayerCollision

      public void onPlayerCollision​(PlayerEntity player)
      Overrides:
      onPlayerCollision in class Entity
    • getName

      public Text getName()
      Specified by:
      getName in interface Nameable
      Overrides:
      getName in class Entity
    • isAttackable

      public boolean isAttackable()
      Overrides:
      isAttackable in class Entity
    • moveToWorld

      @Nullable public Entity moveToWorld​(ServerWorld destination)
      Moves this entity to another world.

      Note all entities except server player entities are completely recreated at the destination.

      Overrides:
      moveToWorld in class Entity
      Returns:
      the entity in the other world
    • getStack

      public ItemStack getStack()
      Returns the item stack contained in this item entity.
    • setStack

      public void setStack​(ItemStack stack)
      Sets the item stack contained in this item entity to stack.
    • onTrackedDataSet

      public void onTrackedDataSet​(TrackedData<?> data)
      Overrides:
      onTrackedDataSet in class Entity
    • getOwner

      @Nullable public UUID getOwner()
      Returns the UUID of the entity to which belongs this item entity, or null if there is not.

      If there is one, the owner is the only entity which can pick up this item entity.

    • setOwner

      public void setOwner​(@Nullable UUID uuid)
      Sets the owner of this item entity to uuid.

      Used when an item is given to an entity, but this entity does not have enough space in its inventory.

    • getThrower

      @Nullable public UUID getThrower()
      Returns the UUID of the entity which created this item entity by throwing an item, or null if it was created otherwise.
    • setThrower

      public void setThrower​(@Nullable UUID uuid)
      Sets the thrower of this item entity to uuid.
    • getItemAge

      @Environment(CLIENT) public int getItemAge()
      Returns the number of ticks since this item entity has been created.

      Increases every tick. When it equals to 6000 ticks (5 minutes), this item entity disappears.

      Unlike Entity.age, it is persistent and not synchronized between the client and the server.

      See Also:
      tick()
    • setToDefaultPickupDelay

      public void setToDefaultPickupDelay()
      Sets the number of ticks before this item entity can be picked up to the default value of 10.
    • resetPickupDelay

      public void resetPickupDelay()
      Sets the number of ticks before this item entity can be picked up to 0.
    • setPickupDelayInfinite

      public void setPickupDelayInfinite()
      Makes this item entity impossible to be picked up by setting its pickup delay to 32767.
    • setPickupDelay

      public void setPickupDelay​(int pickupDelay)
      Sets the number of ticks before this item entity can be picked up to pickupDelay.
    • cannotPickup

      public boolean cannotPickup()
      Returns whether the pickup delay of this item entity is greater than 0.
    • setCovetedItem

      public void setCovetedItem()
    • setDespawnImmediately

      public void setDespawnImmediately()
    • method_27314

      @Environment(CLIENT) public float method_27314​(float float2)
    • createSpawnPacket

      public Packet<?> createSpawnPacket()
      Specified by:
      createSpawnPacket in class Entity
    • method_29271

      @Environment(CLIENT) public ItemEntity method_29271()