Package net.minestom.server.entity
Class ItemEntity
java.lang.Object
net.minestom.server.entity.Entity
net.minestom.server.entity.ItemEntity
- All Implemented Interfaces:
Sound.Emitter
,HoverEventSource<HoverEvent.ShowEntity>
,Shape
,EventHandler<EntityEvent>
,Snapshotable
,Taggable
,TagReadable
,TagWritable
,AcquirableSource<Entity>
,Tickable
,Schedulable
,Viewable
Represents an item on the ground.
-
Field Summary
Fields inherited from class net.minestom.server.entity.Entity
boundingBox, collidesWithEntities, currentChunk, entityMeta, entityType, gravityTickCount, hasPhysics, instance, lastSyncedPosition, lastVelocityWasZero, metadata, onGround, position, preventBlockPlacement, previousPosition, removed, trackingUpdate, vehicle, velocity, viewEngine, viewers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull Acquirable
<? extends ItemEntity> Obtains anAcquirable
.@NotNull ItemEntityMeta
Gets metadata of this entity.@NotNull ItemStack
Gets the item stack on ground.static @Nullable Duration
Gets the update option for the merging feature.float
Gets the merge range.long
Gets the pickup delay in milliseconds, defined bysetPickupDelay(Duration)
.long
Used to know if the ItemEntity can be pickup.boolean
Gets if the item is mergeable.boolean
Gets if the item is currently pickable.void
setItemStack
(@NotNull ItemStack itemStack) Changes the item stack on ground.void
setMergeable
(boolean mergeable) When set to true, closeItemEntity
will try to merge together as a single entity when theirgetItemStack()
is similar and allowed to stack together.static void
setMergeDelay
(@Nullable Duration delay) Changes the merge delay.void
setMergeRange
(float mergeRange) Changes the merge range.void
setPickable
(boolean pickable) Makes the item pickable.void
setPickupDelay
(long delay, @NotNull TemporalUnit temporalUnit) Sets the pickup delay of the ItemEntity.void
setPickupDelay
(Duration delay) Sets the pickup delay of the ItemEntity.void
spawn()
Called when a new instance is set.void
update
(long time) Called each tick.Methods inherited from class net.minestom.server.entity.Entity
addEffect, addPassenger, addViewer, asHoverEvent, autoViewEntities, clearEffects, despawn, editEntityMeta, eventNode, generateId, getAcquirable, getActiveEffects, getAerodynamics, getAliveTicks, getAttachEntityPacket, getBoundingBox, getChunk, getCustomName, getDistance, getDistance, getDistanceSquared, getDistanceSquared, getEffect, getEffectLevel, getEntityId, getEntityType, getEyeHeight, getGravityTickCount, getInstance, getLeashedEntities, getLeashHolder, getLineOfSight, getLineOfSightEntity, getMetadataPacket, getPassengers, getPassengersPacket, getPose, getPosition, getPreviousPosition, getSynchronizationTicks, getUuid, getVehicle, getVelocity, getVelocityForPacket, getVelocityPacket, getViewers, hasEffect, hasEntityCollision, hasLineOfSight, hasLineOfSight, hasNoGravity, hasPassenger, hasPredictableViewers, hasVelocity, intersectBox, intersectBoxSwept, isActive, isAutoViewable, isCustomNameVisible, isGlowing, isInvisible, isOccluded, isOnFire, isOnGround, isRemoved, isSilent, isSneaking, isSprinting, lookAt, lookAt, movementTick, preventBlockPlacement, refreshCoordinate, refreshCurrentChunk, refreshPosition, refreshPosition, refreshPosition, relativeEnd, relativeStart, remove, remove, removeEffect, removePassenger, removeViewer, scheduleNextTick, scheduler, scheduleRemove, scheduleRemove, setAerodynamics, setAutoViewable, setAutoViewEntities, setBoundingBox, setBoundingBox, setCustomName, setCustomNameVisible, setGlowing, setInstance, setInstance, setInstance, setInvisible, setLeashHolder, setNoGravity, setPose, setSilent, setSneaking, setSprinting, setSynchronizationTicks, setVelocity, setView, switchEntityType, synchronizeNextTick, synchronizePosition, tagHandler, takeKnockback, teleport, teleport, teleport, teleport, teleport, teleport, tick, triggerStatus, updateCollisions, updateNewViewer, updateOldViewer, updatePose, updateSnapshot, updateViewableRule, updateViewableRule, updateViewerRule, updateViewerRule
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
Methods inherited from interface net.minestom.server.collision.Shape
intersectEntity, isFaceFull
Methods inherited from interface net.minestom.server.tag.Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTag
Methods inherited from interface net.minestom.server.Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Constructor Details
-
ItemEntity
-
-
Method Details
-
getMergeDelay
Gets the update option for the merging feature.- Returns:
- the merge update option
-
setMergeDelay
Changes the merge delay. Can be set to null to entirely remove the delay.- Parameters:
delay
- the new merge delay
-
update
public void update(long time) Description copied from class:Entity
Called each tick. -
spawn
public void spawn()Description copied from class:Entity
Called when a new instance is set. -
getEntityMeta
Description copied from class:Entity
Gets metadata of this entity. You may want to cast it to specific implementation.- Overrides:
getEntityMeta
in classEntity
- Returns:
- metadata of this entity.
-
getItemStack
Gets the item stack on ground.- Returns:
- the item stack
-
setItemStack
Changes the item stack on ground.- Parameters:
itemStack
- the item stack
-
isPickable
public boolean isPickable()Gets if the item is currently pickable.setPickable(boolean)
needs to be true and the delaygetPickupDelay()
to be long gone.- Returns:
- true if the item is pickable, false otherwise
-
setPickable
public void setPickable(boolean pickable) Makes the item pickable.- Parameters:
pickable
- true to make the item pickable, false otherwise
-
isMergeable
public boolean isMergeable()Gets if the item is mergeable.- Returns:
- true if the entity is mergeable, false otherwise
-
setMergeable
public void setMergeable(boolean mergeable) When set to true, closeItemEntity
will try to merge together as a single entity when theirgetItemStack()
is similar and allowed to stack together.- Parameters:
mergeable
- should the entity merge with otherItemEntity
-
getMergeRange
public float getMergeRange()Gets the merge range.- Returns:
- the merge range
-
setMergeRange
public void setMergeRange(float mergeRange) Changes the merge range.- Parameters:
mergeRange
- the merge range
-
getPickupDelay
public long getPickupDelay()Gets the pickup delay in milliseconds, defined bysetPickupDelay(Duration)
.- Returns:
- the pickup delay
-
setPickupDelay
Sets the pickup delay of the ItemEntity.- Parameters:
delay
- the pickup delaytemporalUnit
- the unit of the delay
-
setPickupDelay
Sets the pickup delay of the ItemEntity.- Parameters:
delay
- the pickup delay
-
getSpawnTime
public long getSpawnTime()Used to know if the ItemEntity can be pickup.- Returns:
- the time in milliseconds since this entity has spawn
-
acquirable
Description copied from interface:AcquirableSource
Obtains anAcquirable
. To safely perform operations on this object, the user must callAcquirable.sync(Consumer)
orAcquirable.lock()
(followed by a subsequent unlock) on the Acquirable instance.- Specified by:
acquirable
in interfaceAcquirableSource<Entity>
- Overrides:
acquirable
in classEntity
- Returns:
- an Acquirable which can be used to synchronize access to this object
-