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
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull ItemEntityMetaGets metadata of this entity.@NotNull ItemStackGets the item stack on ground.static @Nullable DurationGets the update option for the merging feature.floatGets the merge range.longGets the pickup delay in milliseconds, defined bysetPickupDelay(Duration).longUsed to know if the ItemEntity can be pickup.booleanGets if the item is mergeable.booleanGets if the item is currently pickable.voidsetItemStack(@NotNull 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, @NotNull 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 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, updateViewerRuleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEventMethods inherited from interface net.minestom.server.permission.PermissionHandler
addPermission, getPermission, hasPermission, hasPermission, hasPermission, removePermission, removePermissionMethods inherited from interface net.minestom.server.collision.Shape
intersectEntity, isFaceFullMethods 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:EntityCalled each tick. -
spawn
public void spawn()Description copied from class:EntityCalled when a new instance is set. -
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
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, 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
public long getSpawnTime()Used to know if the ItemEntity can be pickup.- Returns:
- the time in milliseconds since this entity has spawn
-