Interface ItemEntity
- All Superinterfaces:
Entity, HoverEventSource<HoverEvent.ShowEntity>, SchedulerSource, Sound.Emitter, Sound.Source.Provider
A stack of items lying on the ground (
minecraft:item), dropped by a player, thrown out of
a window or spilled by a block.
It falls, slides, merges with similar stacks nearby and despawns after 6000 ticks. Once its pickup delay is over, the first player who walks over it takes as much of it as fits in their inventory.
Like every entity, change it from the region thread owning its chunk.
- Since:
- 0.1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHow many ticks an item stays on the ground before it despawns: five minutes.static final intThe pickup delay of an item spilled by a block or a window: half a second.static final intA pickup delay that never runs out: nobody can pick the item up, and it never merges with another one.static final intThe pickup delay of an item a player throws away, so that it does not land straight back in their inventory: two seconds. -
Method Summary
Modifier and TypeMethodDescriptionintage()Returns how many ticks this item has been on the ground.booleanReturns whether this item stays on the ground forever.item()Returns the stack this entity carries, never empty while the entity is alive.booleanonGround()Returns whether the item rests on a block.owner()Returns the only player allowed to pick this item up,nullwhen anybody may.intReturns how many ticks are left before the item may be picked up,0when it may be picked up now.voidsetAge(int ticks) voidReplaces the stack this entity carries.voidRestricts who may pick this item up.voidsetPickupDelay(int ticks) Sets how many ticks are left before the item may be picked up.voidsetThrower(@Nullable UUID thrower) Sets the entity that dropped or threw this item.voidsetUnlimitedLifetime(boolean unlimited) Sets whether this item stays on the ground forever instead of despawning after 6000 ticks.voidsetVelocity(double x, double y, double z) Overwrites the velocity, in blocks per tick.thrower()Returns the entity that dropped or threw this item,nullwhen unknown.doubleReturns the velocity along x, in blocks per tick.doubleReturns the velocity along y, in blocks per tick, positive upwards.doubleReturns the velocity along z, in blocks per tick.Methods inherited from interface Entity
chunk, displayName, entityId, isRemoved, location, remove, server, teleport, teleport, teleport, type, uuid, worldMethods inherited from interface HoverEventSource
asHoverEvent, asHoverEventMethods inherited from interface SchedulerSource
execute, executeDelayed, isOwnedByCurrentThreadMethods inherited from interface Sound.Source.Provider
soundSource
-
Field Details
-
DEFAULT_LIFETIME
static final int DEFAULT_LIFETIMEHow many ticks an item stays on the ground before it despawns: five minutes.- Since:
- 0.1.0
- See Also:
-
INFINITE_PICKUP_DELAY
static final int INFINITE_PICKUP_DELAYA pickup delay that never runs out: nobody can pick the item up, and it never merges with another one.- Since:
- 0.1.0
- See Also:
-
THROWN_PICKUP_DELAY
static final int THROWN_PICKUP_DELAYThe pickup delay of an item a player throws away, so that it does not land straight back in their inventory: two seconds.- Since:
- 0.1.0
- See Also:
-
DEFAULT_PICKUP_DELAY
static final int DEFAULT_PICKUP_DELAYThe pickup delay of an item spilled by a block or a window: half a second.- Since:
- 0.1.0
- See Also:
-
-
Method Details
-
item
ItemStack item()Returns the stack this entity carries, never empty while the entity is alive.- Returns:
- the stack this entity carries, never empty while the entity is alive
- Since:
- 0.1.0
-
setItem
Replaces the stack this entity carries. An empty stack removes the entity.- Parameters:
item- the new stack- Since:
- 0.1.0
-
pickupDelay
int pickupDelay()Returns how many ticks are left before the item may be picked up,0when it may be picked up now.- Returns:
- how many ticks are left before the item may be picked up,
0when it may be picked up now - Since:
- 0.1.0
-
setPickupDelay
void setPickupDelay(int ticks) Sets how many ticks are left before the item may be picked up.- Parameters:
ticks- the delay,0for right away,INFINITE_PICKUP_DELAYfor never- Since:
- 0.1.0
-
age
int age()Returns how many ticks this item has been on the ground.- Returns:
- how many ticks this item has been on the ground
- Since:
- 0.1.0
-
setAge
-
hasUnlimitedLifetime
boolean hasUnlimitedLifetime()Returns whether this item stays on the ground forever.- Returns:
- whether this item stays on the ground forever
- Since:
- 0.1.0
-
setUnlimitedLifetime
void setUnlimitedLifetime(boolean unlimited) Sets whether this item stays on the ground forever instead of despawning after 6000 ticks.- Parameters:
unlimited-trueto keep the item forever- Since:
- 0.1.0
-
owner
-
setOwner
-
thrower
-
setThrower
-
velocityX
double velocityX()Returns the velocity along x, in blocks per tick.- Returns:
- the velocity along x, in blocks per tick
- Since:
- 0.1.0
-
velocityY
double velocityY()Returns the velocity along y, in blocks per tick, positive upwards.- Returns:
- the velocity along y, in blocks per tick, positive upwards
- Since:
- 0.1.0
-
velocityZ
double velocityZ()Returns the velocity along z, in blocks per tick.- Returns:
- the velocity along z, in blocks per tick
- Since:
- 0.1.0
-
setVelocity
void setVelocity(double x, double y, double z) Overwrites the velocity, in blocks per tick.- Parameters:
x- the velocity along xy- the velocity along y, positive upwardsz- the velocity along z- Since:
- 0.1.0
-
onGround
boolean onGround()Returns whether the item rests on a block.- Returns:
- whether the item rests on a block
- Since:
- 0.1.0
-