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>
,PermissionHandler
,Snapshotable
,Taggable
,TagReadable
,TagWritable
,Tickable
,Schedulable
,Viewable
Represents an item on the ground.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minestom.server.entity.Entity
Entity.Pose
-
Field Summary
Fields inherited from class net.minestom.server.entity.Entity
boundingBox, currentChunk, entityMeta, entityType, gravityTickCount, hasCollision, hasPhysics, instance, lastSyncedPosition, lastVelocityWasZero, metadata, onGround, position, previousPosition, removed, trackingUpdate, uuid, vehicle, velocity, viewEngine, viewers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@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, getAllPermissions, getAttachEntityPacket, getBoundingBox, getChunk, getCustomName, getDistance, getDistance, getDistanceSquared, getDistanceSquared, getEffect, getEffectLevel, getEntity, getEntity, getEntityId, getEntityType, getEyeHeight, getGravityTickCount, getInstance, getLeashedEntities, getLeashHolder, getLineOfSight, getLineOfSightEntity, getMetadataPacket, getPassengers, getPassengersPacket, getPose, getPosition, getPreviousPosition, getSynchronizationTicks, getUuid, getVehicle, getVelocity, getVelocityForPacket, getVelocityPacket, getViewers, hasCollision, hasEffect, hasLineOfSight, hasLineOfSight, hasNoGravity, hasPassenger, hasPredictableViewers, hasVelocity, intersectBox, intersectBoxSwept, isActive, isAutoViewable, isCustomNameVisible, isGlowing, isInvisible, isOccluded, isOnFire, isOnGround, isRemoved, isSilent, isSneaking, isSprinting, lookAt, lookAt, movementTick, 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, setOnFire, setPose, setSilent, setSneaking, setSprinting, setSynchronizationTicks, setUuid, setVelocity, setView, switchEntityType, synchronizeNextTick, synchronizePosition, tagHandler, takeKnockback, teleport, teleport, tick, triggerStatus, 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.permission.PermissionHandler
addPermission, getPermission, hasPermission, hasPermission, hasPermission, removePermission, removePermission
Methods inherited from interface net.minestom.server.collision.Shape
intersectEntity, isFaceFull
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
-