Class ItemEntity
java.lang.Object
net.minestom.server.entity.Entity
net.minestom.server.entity.ItemEntity
- All Implemented Interfaces:
Identified, Pointered, Sound.Emitter, HoverEventSource<HoverEvent.ShowEntity>, Shape, DataComponent.Holder, EventHandler<EntityEvent>, Snapshotable, Taggable, TagReadable, TagWritable, AcquirableSource<Entity>, Tickable, Schedulable, Viewable
Represents an item on the ground.
-
Field Summary
Fields inherited from class Entity
boundingBox, collidesWithEntities, currentChunk, ENTITY_POINTERS_SUPPLIER, entityMeta, entityType, gravityTickCount, hasPhysics, headRotation, instance, lastSyncedPosition, lastVelocityWasZero, metadata, onGround, position, preventBlockPlacement, previousPosition, removed, trackingUpdate, vehicle, velocity, viewEngine, viewers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAcquirable<? extends ItemEntity> Obtains anAcquirable.Gets metadata of this entity.Gets the item stack on ground.Gets the update option for the merging feature.floatGets the merge range.longGets the pickup delay in milliseconds, defined bysetPickupDelay(Duration).longDeprecated, for removal: This API element is subject to removal in a future version.longUsed to know if the ItemEntity can be picked up.booleanGets if the item is mergeable.booleanGets if the item is currently pickable.voidvoidsetItemStack(ItemStack itemStack) Changes the item stack on ground.voidsetMergeable(boolean mergeable) When set to true, closeItemEntitywill try to merge together as a single entity when theirgetItemStack()is similar and allowed to stack together.static voidsetMergeDelay(@Nullable Duration delay) Changes the merge delay.voidsetMergeRange(float mergeRange) Changes the merge range.voidsetPickable(boolean pickable) Makes the item pickable.voidsetPickupDelay(long delay, TemporalUnit temporalUnit) Sets the pickup delay of the ItemEntity.voidsetPickupDelay(Duration delay) Sets the pickup delay of the ItemEntity.voidspawn()Called when a new instance is set.voidupdate(long time) Called each tick.Methods inherited from class Entity
addEffect, addPassenger, addViewer, asHoverEvent, autoViewEntities, clearEffects, despawn, editEntityMeta, eventNode, generateId, get, getAcquirable, getActiveEffects, getAerodynamics, getAliveTicks, getAttachEntityPacket, getBoundingBox, getChunk, getCustomName, getDistance, getDistance, getDistanceSquared, getDistanceSquared, getEffect, getEffectLevel, getEntityId, getEntityType, getEyeHeight, getGravityTickCount, getHeadRotation, getInstance, getLeashedEntities, getLeashHolder, getLineOfSight, getLineOfSightEntity, getMetadataPacket, getPassengers, getPassengersPacket, getPose, getPosition, getPreviousPosition, getSpawnPacket, getSynchronizationTicks, getUuid, getVehicle, getVelocity, getVelocityForPacket, getVelocityPacket, getViewers, hasEffect, hasEntityCollision, hasLineOfSight, hasLineOfSight, hasNoGravity, hasPassenger, hasPredictableViewers, hasVelocity, identity, intersectBox, intersectBoxSwept, isActive, isAutoViewable, isCustomNameVisible, isGlowing, isInvisible, isOccluded, isOnFire, isOnGround, isRemoved, isSilent, isSneaking, isSprinting, lookAt, lookAt, pointers, preventBlockPlacement, refreshCoordinate, refreshCurrentChunk, refreshPosition, refreshPosition, refreshPosition, relativeEnd, relativeStart, remove, remove, removeEffect, removePassenger, removeViewer, scheduleNextTick, scheduler, scheduleRemove, scheduleRemove, set, setAerodynamics, setAutoViewable, setAutoViewEntities, setBoundingBox, setBoundingBox, setCustomName, setCustomNameVisible, setGlowing, setInstance, setInstance, setInstance, setInvisible, setLeashHolder, setNoGravity, setPose, setPositionInternal, setSilent, setSneaking, setSprinting, setSynchronizationTicks, setVelocity, setView, setView, switchEntityType, synchronizeNextTick, synchronizePosition, tagHandler, takeKnockback, teleport, teleport, teleport, teleport, teleport, teleport, tick, triggerStatus, updateCollisions, updateNewViewer, updateOldViewer, updatePose, updateSnapshot, updateViewableRule, updateViewableRule, updateViewerRule, updateViewerRuleMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DataComponent.Holder
get, hasMethods inherited from interface HoverEventSource
asHoverEventMethods inherited from interface Pointered
get, getOrDefault, getOrDefaultFromMethods inherited from interface Shape
intersectEntity, isFaceFullMethods inherited from interface Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTagMethods inherited from interface Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Constructor Details
-
ItemEntity
-
-
Method Details
-
getMergeDelay
-
setMergeDelay
-
update
-
movementTick
public void movementTick()- Overrides:
movementTickin classEntity
-
spawn
-
getEntityMeta
Description copied from class:EntityGets metadata of this entity. You may want to cast it to specific implementation.- Overrides:
getEntityMetain classEntity- Returns:
- metadata of this entity.
-
getItemStack
-
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, closeItemEntitywill 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
Deprecated, for removal: This API element is subject to removal in a future version.usegetTimeSinceSpawn()instead, does the same thing with better namingUsed to know if the ItemEntity can be picked up.- Returns:
- the elapsed time in milliseconds since this entity has spawned
-
getTimeSinceSpawn
public long getTimeSinceSpawn()Used to know if the ItemEntity can be picked up.- Returns:
- the elapsed time in milliseconds since this entity has spawned
-
acquirable
Description copied from interface:AcquirableSourceObtains anAcquirable. To safely perform operations on this object, the user must callAcquirable.sync(Consumer),Acquirable.applySync(Function), orAcquirable.lock()(followed by a subsequent unlock) on the Acquirable instance.- Specified by:
acquirablein interfaceAcquirableSource<Entity>- Overrides:
acquirablein classEntity- Returns:
- an Acquirable which can be used to synchronize access to this object
-
getTimeSinceSpawn()instead, does the same thing with better naming