Class Entity
- All Implemented Interfaces:
Identified, Pointered, Sound.Emitter, HoverEventSource<HoverEvent.ShowEntity>, Shape, DataComponent.Holder, EventHandler<EntityEvent>, Snapshotable, Taggable, TagReadable, TagWritable, AcquirableSource<Entity>, Tickable, Schedulable, Viewable
- Direct Known Subclasses:
EntityProjectile, ExperienceOrb, ItemEntity, LivingEntity
To create your own entity you probably want to extend LivingEntity or EntityCreature instead.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BoundingBoxprotected booleanprotected Chunkprotected static PointersSupplier<Entity> protected EntityMetaprotected EntityTypeprotected intprotected booleanprotected floatprotected Instanceprotected Posprotected booleanprotected MetadataHolderprotected booleanprotected Posprotected booleanprotected Posprotected booleanprotected final EntityTracker.Update<Entity> protected Entityprotected Vecprotected final net.minestom.server.entity.EntityView -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAcquirable<? extends Entity> Obtains anAcquirable.voidAdds an effect to an entity.voidaddPassenger(Entity entity) Adds a new passenger to this entity.final booleanAdds a viewer.booleanGets if surrounding entities are automatically visible by this.voidRemoves all the effects currently applied to the entity.protected voiddespawn()Called right before an entity is removed<TMeta extends EntityMeta>
voideditEntityMeta(Class<TMeta> metaClass, Consumer<TMeta> editor) Do a batch edit of this entity's metadata.static intGenerate and return a new unique entity id.<T> Tget(DataComponent<T> component) <T extends Entity>
Acquirable<T> Deprecated.Gets all the potion effect of this entity.Gets the aerodynamics; how the entity behaves in the air.longGets the number of ticks this entity has been active for.protected AttachEntityPacketReturns the current bounding box (based on pose).getChunk()Convenient method to get the entity current chunk.Deprecated.useDataComponents.CUSTOM_NAMEinstead.doublegetDistance(Point point) doublegetDistance(Entity entity) Gets the distance between two entities.doublegetDistanceSquared(Point point) doublegetDistanceSquared(Entity entity) Gets the distance squared between two entities.getEffect(PotionEffect effect) Gets the TimedPotion of the specified effect.intgetEffectLevel(PotionEffect effect) Gets the level of the specified effect.intEach entity has an unique id (server-wide) which will change after a restart.Gets metadata of this entity.Returns the entity type.doubleGets the entity eye height.intGets the number of tick this entity has been applied gravity.floatGets the entity head rotation.Gets the entity current instance.Gets the entities that this entity is leashing.Gets the current leash holder.getLineOfSight(int maxDistance) Gets the line of sight of the entity.getLineOfSightEntity(double range, Predicate<Entity> predicate) Gets first entity on the line of sight of the current one that matches the given predicate.Gets anEntityMetaDataPacketsent when adding viewers.Gets the entity passengers.protected SetPassengersPacketgetPose()Gets the current entity pose.Gets the entity position.Gets the previous entity position.protected SpawnEntityPacketlongReturns the current synchronization interval.getUuid()Gets the entityUUID.Gets the entity vehicle or null.Gets the entity current velocity.protected Vecprotected EntityVelocityPacketGets all the viewers of this viewable element.booleanhasEffect(PotionEffect effect) If the entity has the specified effect.booleanbooleanhasLineOfSight(Entity entity) booleanhasLineOfSight(Entity entity, boolean exactView) Raycasts current entity's eye position to target eye position.booleanGets the noGravity metadata field.booleanGets if the entity has any passenger.booleanGets if this entity's viewers (surrounding players) can be predicted from surrounding chunks.booleanGets if the entity currently has a velocity applied.identity()booleanintersectBox(Point positionRelative, BoundingBox boundingBox) Checks if two bounding boxes intersect.booleanintersectBoxSwept(Point rayStart, Point rayDirection, Point shapePos, BoundingBox moving, SweepResult finalResult) Checks if a moving bounding box will hit this shape.booleanisActive()Returns false just after instantiation, set to true after callingsetInstance(Instance).booleanGets if this entity is automatically sent to surrounding players.booleanGets the custom name visible metadata field.booleanGets if the entity is glowing or not.booleanGets if the entity is invisible or not.booleanisOccluded(Shape shape, BlockFace face) booleanisOnFire()Gets if the entity is on fire.booleanbooleanGets if this entity has been removed.booleanisSilent()booleanGets if the entity is sneaking.booleanGets if the player is sprinting.voidChanges the view of the entity so that it looks in a direction to the given position if it is different from the entity's current position.voidChanges the view of the entity so that it looks in a direction to the given entity.protected voidpointers()booleanprotected voidrefreshCoordinate(Point newPosition) Used to refresh the entity and its passengers position - put the entity in the right instance chunk - update the viewable chunks (load and unload) - add/remove players from the viewers list ifisAutoViewable()is enabledprotected voidrefreshCurrentChunk(Chunk currentChunk) voidrefreshPosition(Pos newPosition) voidrefreshPosition(Pos newPosition, boolean ignoreView) voidrefreshPosition(Pos newPosition, boolean ignoreView, boolean sendPackets) Updates internal fields and sends updates.Relative EndRelative Startvoidremove()Removes the entity from the server immediately.protected voidremove(boolean permanent) voidremoveEffect(PotionEffect effect) Removes effect from entity, if it has it.voidremovePassenger(Entity entity) Removes a passenger to this entity.final booleanremoveViewer(Player player) Removes a viewer.voidscheduleNextTick(Consumer<Entity> callback) Schedules a task to be run during the next entity tick.voidscheduleRemove(long delay, TemporalUnit temporalUnit) Triggersremove()after the specified time.voidscheduleRemove(Duration delay) Triggersremove()after the specified time.<T> voidset(DataComponent<T> component, T value) voidsetAerodynamics(Aerodynamics aerodynamics) Sets the aerodynamics; how the entity behaves in the air.voidsetAutoViewable(boolean autoViewable) Decides if this entity should be auto-viewable by nearby players.voidsetAutoViewEntities(boolean autoViewer) Decides if surrounding entities must be visible.voidsetBoundingBox(double width, double height, double depth) Changes the internal entity standing bounding box.voidsetBoundingBox(BoundingBox boundingBox) Changes the internal entity standing bounding box.voidsetCustomName(@Nullable Component customName) Deprecated.useDataComponents.CUSTOM_NAMEinstead.voidsetCustomNameVisible(boolean customNameVisible) Changes the internal custom name visible field and send aEntityMetaDataPacketto update the entity state to its viewers.voidsetGlowing(boolean glowing) Sets or remove the entity glowing effect.setInstance(Instance instance) Changes the entity instance.setInstance(Instance instance, Point spawnPosition) setInstance(Instance instance, Pos spawnPosition) Changes the entity instance, i.e.voidsetInvisible(boolean invisible) Changes the internal invisible value and send aEntityMetaDataPacketto make visible or invisible the entity to its viewers.voidsetLeashHolder(@Nullable Entity entity) Sets the leash holder to this entity.voidsetNoGravity(boolean noGravity) Changes the noGravity metadata field and change the gravity behaviour accordingly.voidsetPose(EntityPose pose) Changes the entity pose.protected voidsetPositionInternal(Pos newPosition, float headRotation) voidsetSilent(boolean silent) voidsetSneaking(boolean sneaking) Makes the entity sneak.voidsetSprinting(boolean sprinting) Makes the entity sprint.voidsetSynchronizationTicks(long ticks) Set the tick period until this entity's position is synchronized.voidsetVelocity(Vec velocity) Changes the entity velocity and callsEntityVelocityEvent.voidsetView(float yaw, float pitch) Changes the view of the entity.voidsetView(float yaw, float pitch, float headRotation) Changes the view and head rotation of the entity.voidspawn()Called when a new instance is set.voidswitchEntityType(EntityType entityType) Changes the entity type of this entity.voidAsks for a position synchronization to happen during next entity tick.protected voidUsed to synchronize entity position with viewers by sending a fullEntityPositionSyncPacketto viewers.voidtakeKnockback(float strength, double x, double z) Applies knockback to the entityTeleports the entity only if the chunk atpositionis loaded or ifInstance.hasEnabledAutoChunkLoad()returns true.voidtick(long time) Updates the entity, called every tick.voidtriggerStatus(byte status) Entity statuses can be found here.voidupdate(long time) Called each tick.protected voidvoidupdateNewViewer(Player player) Called when a new viewer must be shown.voidupdateOldViewer(Player player) Called when a viewer must be destroyed.protected voidupdateSnapshot(SnapshotUpdater updater) Updates the currently cached snapshot if required.voidvoidupdateViewableRule(@Nullable Predicate<Player> predicate) voidvoidupdateViewerRule(@Nullable Predicate<Entity> predicate) Methods 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
-
Field Details
-
ENTITY_POINTERS_SUPPLIER
-
instance
-
currentChunk
-
position
-
headRotation
protected float headRotation -
previousPosition
-
lastSyncedPosition
-
onGround
protected boolean onGround -
boundingBox
-
vehicle
-
velocity
-
lastVelocityWasZero
protected boolean lastVelocityWasZero -
hasPhysics
protected boolean hasPhysics -
collidesWithEntities
protected boolean collidesWithEntities -
preventBlockPlacement
protected boolean preventBlockPlacement -
gravityTickCount
protected int gravityTickCount -
trackingUpdate
-
viewEngine
protected final net.minestom.server.entity.EntityView viewEngine -
viewers
-
removed
protected boolean removed -
entityType
-
metadata
-
entityMeta
-
-
Constructor Details
-
Entity
-
Entity
-
-
Method Details
-
setPositionInternal
-
scheduleNextTick
-
generateId
public static int generateId()Generate and return a new unique entity id.Useful if you want to spawn entities using packet but don't risk to have duplicated id.
- Returns:
- a newly generated entity id
-
update
public void update(long time) Called each tick.- Parameters:
time- time of the update in milliseconds. This may only be used as a delta and has no meaning in the real world
-
spawn
public void spawn()Called when a new instance is set. -
despawn
protected void despawn()Called right before an entity is removed -
isOnGround
public boolean isOnGround() -
getEntityMeta
Gets metadata of this entity. You may want to cast it to specific implementation.- Returns:
- metadata of this entity.
-
get
- Specified by:
getin interfaceDataComponent.Holder
-
set
-
editEntityMeta
public <TMeta extends EntityMeta> void editEntityMeta(Class<TMeta> metaClass, Consumer<TMeta> editor) Do a batch edit of this entity's metadata. -
teleport
-
teleport
-
teleport
public CompletableFuture<Void> teleport(Pos position, long @Nullable [] chunks, @MagicConstant(flagsFromClass=RelativeFlags.class) int flags) -
teleport
public CompletableFuture<Void> teleport(Pos position, Vec velocity, long @Nullable [] chunks, @MagicConstant(flagsFromClass=RelativeFlags.class) int flags) -
teleport
public CompletableFuture<Void> teleport(Pos position, long @Nullable [] chunks, @MagicConstant(flagsFromClass=RelativeFlags.class) int flags, boolean shouldConfirm) -
teleport
public CompletableFuture<Void> teleport(Pos position, Vec velocity, long @Nullable [] chunks, @MagicConstant(flagsFromClass=RelativeFlags.class) int flags, boolean shouldConfirm) Teleports the entity only if the chunk atpositionis loaded or ifInstance.hasEnabledAutoChunkLoad()returns true.- Parameters:
position- the teleport positionchunks- the chunk indexes to load before teleporting the entity, indexes are fromCoordConversion.chunkIndex(int, int), can be null or empty to only load the chunk atpositionflags- flags used to teleport the entity relatively rather than absolutely useRelativeFlagsto see available flagsshouldConfirm- if false, the teleportation will be done without confirmation- Throws:
IllegalStateException- if you try to teleport an entity before settings its instance
-
setView
public void setView(float yaw, float pitch) Changes the view of the entity. The head rotation will be updated to the yaw value.- Parameters:
yaw- the new yawpitch- the new pitch
-
setView
public void setView(float yaw, float pitch, float headRotation) Changes the view and head rotation of the entity. This is only really useful for mobs whose heads are looking in a different direction than their body.The client has a lot of prediction on this front, so using your own logic for this might not produce the desired result. For example: if the entity is not moving, the body will automatically rotate towards the head after a few ticks.
- Parameters:
yaw- the new yawpitch- the new pitchheadRotation- the new head rotation
-
lookAt
Changes the view of the entity so that it looks in a direction to the given position if it is different from the entity's current position.- Parameters:
point- the point to look at.
-
lookAt
Changes the view of the entity so that it looks in a direction to the given entity.- Parameters:
entity- the entity to look at.- Throws:
IllegalArgumentException- if the entities are not in the same instance
-
isAutoViewable
public boolean isAutoViewable()Gets if this entity is automatically sent to surrounding players. True by default.- Returns:
- true if the entity is automatically viewable for close players, false otherwise
-
setAutoViewable
public void setAutoViewable(boolean autoViewable) Decides if this entity should be auto-viewable by nearby players.- Parameters:
autoViewable- true to add surrounding players, false to remove- See Also:
-
updateViewableRule
-
updateViewableRule
public void updateViewableRule() -
autoViewEntities
public boolean autoViewEntities()Gets if surrounding entities are automatically visible by this. True by default.- Returns:
- true if surrounding entities are visible by this
-
setAutoViewEntities
public void setAutoViewEntities(boolean autoViewer) Decides if surrounding entities must be visible.- Parameters:
autoViewer- true to add view surrounding entities, false to remove
-
updateViewerRule
-
updateViewerRule
public void updateViewerRule() -
addViewer
-
removeViewer
Description copied from interface:ViewableRemoves a viewer.- Specified by:
removeViewerin interfaceViewable- Parameters:
player- the viewer to remove- Returns:
- true if the player has been removed, false otherwise (could be because he was not a viewer)
-
updateNewViewer
-
updateOldViewer
-
getViewers
Description copied from interface:ViewableGets all the viewers of this viewable element.- Specified by:
getViewersin interfaceViewable- Returns:
- A Set containing all the element's viewers
-
hasPredictableViewers
public boolean hasPredictableViewers()Gets if this entity's viewers (surrounding players) can be predicted from surrounding chunks. -
switchEntityType
Changes the entity type of this entity.Works by changing the internal entity type field and by calling
removeViewer(Player)followed byaddViewer(Player)to all current viewers.Be aware that this only change the visual of the entity, the
BoundingBoxwill not be modified.- Parameters:
entityType- the new entity type
-
tick
public void tick(long time) Updates the entity, called every tick.Ignored if
getInstance()returns null. -
movementTick
-
getAliveTicks
public long getAliveTicks()Gets the number of ticks this entity has been active for.- Returns:
- the number of ticks this entity has been active for
-
getEntityId
public int getEntityId()Each entity has an unique id (server-wide) which will change after a restart.- Returns:
- the unique entity id
- See Also:
-
getEntityType
-
getUuid
-
isActive
public boolean isActive()Returns false just after instantiation, set to true after callingsetInstance(Instance).- Returns:
- true if the entity has been linked to an instance, false otherwise
-
getBoundingBox
Returns the current bounding box (based on pose). Is used to check collision with coordinates or other blocks/entities.- Returns:
- the entity bounding box
-
setBoundingBox
public void setBoundingBox(double width, double height, double depth) Changes the internal entity standing bounding box. When the pose is not standing, a different bounding box may be used for collision.WARNING: this does not change the entity hit-box which is client-side.
- Parameters:
width- the bounding box X sizeheight- the bounding box Y sizedepth- the bounding box Z size
-
setBoundingBox
Changes the internal entity standing bounding box. When the pose is not standing, a different bounding box may be used for collision.WARNING: this does not change the entity hit-box which is client-side.
- Parameters:
boundingBox- the new bounding box
-
getChunk
-
refreshCurrentChunk
-
getInstance
Gets the entity current instance.- Returns:
- the entity instance, can be null if the entity doesn't have an instance yet
-
setInstance
Changes the entity instance, i.e. spawns it.- Parameters:
instance- the new instance of the entityspawnPosition- the spawn position for the entity.- Returns:
- a
CompletableFuturecalled once the entity's instance has been set, this is due to chunks needing to load - Throws:
IllegalStateException- ifinstancehas not been registered inInstanceManager
-
setInstance
-
setInstance
Changes the entity instance.- Parameters:
instance- the new instance of the entity- Returns:
- a
CompletableFuturecalled once the entity's instance has been set, this is due to chunks needing to load - Throws:
NullPointerException- ifinstanceis nullIllegalStateException- ifinstancehas not been registered inInstanceManager
-
getVelocity
-
setVelocity
Changes the entity velocity and callsEntityVelocityEvent.The final velocity can be cancelled or modified by the event.
- Parameters:
velocity- the new entity velocity
-
hasVelocity
public boolean hasVelocity()Gets if the entity currently has a velocity applied.- Returns:
- true if the entity is moving
-
getAerodynamics
Gets the aerodynamics; how the entity behaves in the air.- Returns:
- the aerodynamic properties this entity is using
-
setAerodynamics
Sets the aerodynamics; how the entity behaves in the air.- Parameters:
aerodynamics- the new aerodynamic properties
-
getGravityTickCount
public int getGravityTickCount()Gets the number of tick this entity has been applied gravity.- Returns:
- the number of tick of which gravity has been consequently applied
-
getDistance
-
getDistance
Gets the distance between two entities.- Parameters:
entity- the entity to get the distance from- Returns:
- the distance between this and
entity
-
getDistanceSquared
-
getDistanceSquared
Gets the distance squared between two entities.- Parameters:
entity- the entity to get the distance from- Returns:
- the distance squared between this and
entity
-
getVehicle
-
addPassenger
Adds a new passenger to this entity.- Parameters:
entity- the new passenger- Throws:
NullPointerException- ifentityis nullIllegalStateException- ifgetInstance()returns null or the passenger cannot be added
-
removePassenger
Removes a passenger to this entity.- Parameters:
entity- the passenger to remove- Throws:
NullPointerException- ifentityis nullIllegalStateException- ifgetInstance()returns null
-
hasPassenger
public boolean hasPassenger()Gets if the entity has any passenger.- Returns:
- true if the entity has any passenger, false otherwise
-
getPassengers
-
getPassengersPacket
-
getLeashedEntities
-
getLeashHolder
-
setLeashHolder
-
getAttachEntityPacket
-
triggerStatus
public void triggerStatus(byte status) Entity statuses can be found here.- Parameters:
status- the status to trigger
-
isOnFire
public boolean isOnFire()Gets if the entity is on fire.- Returns:
- true if the entity is in fire, false otherwise
-
isSneaking
public boolean isSneaking()Gets if the entity is sneaking.WARNING: this can be bypassed by hacked client, this is only what the client told the server.
- Returns:
- true if the player is sneaking
-
setSneaking
public void setSneaking(boolean sneaking) Makes the entity sneak.WARNING: this will not work for the client itself.
- Parameters:
sneaking- true to make the entity sneak
-
isSprinting
public boolean isSprinting()Gets if the player is sprinting.WARNING: this can be bypassed by hacked client, this is only what the client told the server.
- Returns:
- true if the player is sprinting
-
setSprinting
public void setSprinting(boolean sprinting) Makes the entity sprint.WARNING: this will not work on the client itself.
- Parameters:
sprinting- true to make the entity sprint
-
isInvisible
public boolean isInvisible()Gets if the entity is invisible or not.- Returns:
- true if the entity is invisible, false otherwise
-
setInvisible
public void setInvisible(boolean invisible) Changes the internal invisible value and send aEntityMetaDataPacketto make visible or invisible the entity to its viewers.- Parameters:
invisible- true to set the entity invisible, false otherwise
-
isGlowing
public boolean isGlowing()Gets if the entity is glowing or not.- Returns:
- true if the entity is glowing, false otherwise
-
setGlowing
public void setGlowing(boolean glowing) Sets or remove the entity glowing effect.- Parameters:
glowing- true to make the entity glows, false otherwise
-
getPose
-
setPose
Changes the entity pose.The internal
crouchedandswimmingfield will be updated accordingly.- Parameters:
pose- the new entity pose
-
updatePose
protected void updatePose() -
getCustomName
Deprecated.useDataComponents.CUSTOM_NAMEinstead.Gets the entity custom name.- Returns:
- the custom name of the entity, null if there is not
-
setCustomName
Deprecated.useDataComponents.CUSTOM_NAMEinstead.Changes the entity custom name.- Parameters:
customName- the custom name of the entity, null to remove it
-
isCustomNameVisible
public boolean isCustomNameVisible()Gets the custom name visible metadata field.- Returns:
- true if the custom name is visible, false otherwise
-
setCustomNameVisible
public void setCustomNameVisible(boolean customNameVisible) Changes the internal custom name visible field and send aEntityMetaDataPacketto update the entity state to its viewers.- Parameters:
customNameVisible- true to make the custom name visible, false otherwise
-
isSilent
public boolean isSilent() -
setSilent
public void setSilent(boolean silent) -
hasNoGravity
public boolean hasNoGravity()Gets the noGravity metadata field.- Returns:
- true if the entity ignore gravity, false otherwise
-
setNoGravity
public void setNoGravity(boolean noGravity) Changes the noGravity metadata field and change the gravity behaviour accordingly.- Parameters:
noGravity- should the entity ignore gravity
-
refreshPosition
-
refreshPosition
-
refreshPosition
-
refreshCoordinate
Used to refresh the entity and its passengers position - put the entity in the right instance chunk - update the viewable chunks (load and unload) - add/remove players from the viewers list ifisAutoViewable()is enabledWARNING: unsafe, should only be used internally in Minestom. Use
teleport(Pos)instead.- Parameters:
newPosition- the new position
-
getPosition
-
getHeadRotation
public float getHeadRotation()Gets the entity head rotation. In most cases, this will be the same as their yaw. It might be different for mobs which are looking in a different direction than their body.The head rotation can be changed using
setView(float, float, float).- Returns:
- the head rotation
-
getPreviousPosition
Gets the previous entity position.- Returns:
- the previous position of the entity
-
getEyeHeight
public double getEyeHeight()Gets the entity eye height.- Returns:
- the entity eye height
-
getActiveEffects
Gets all the potion effect of this entity.- Returns:
- an unmodifiable list of all this entity effects
-
addEffect
Adds an effect to an entity.- Parameters:
potion- The potion to add
-
removeEffect
Removes effect from entity, if it has it.- Parameters:
effect- The effect to remove
-
hasEffect
If the entity has the specified effect.- Parameters:
effect- the effect to check
-
getEffect
Gets the TimedPotion of the specified effect.- Parameters:
effect- the effect type- Returns:
- the effect, null if not found
-
getEffectLevel
Gets the level of the specified effect.- Parameters:
effect- the effect type- Returns:
- the effect level, -1 if not found
-
clearEffects
public void clearEffects()Removes all the effects currently applied to the entity. -
remove
public void remove()Removes the entity from the server immediately.WARNING: this does not trigger
EntityDeathEvent. -
remove
protected void remove(boolean permanent) -
isRemoved
public boolean isRemoved()Gets if this entity has been removed.- Returns:
- true if this entity is removed
-
scheduleRemove
Triggersremove()after the specified time.- Parameters:
delay- the time before removing the entity, 0 to cancel the removingtemporalUnit- the unit of the delay
-
scheduleRemove
-
getVelocityForPacket
-
getSpawnPacket
-
getVelocityPacket
-
getMetadataPacket
Gets anEntityMetaDataPacketsent when adding viewers. Used for synchronization.- Returns:
- The
EntityMetaDataPacketrelated to this entity
-
synchronizePosition
Used to synchronize entity position with viewers by sending a fullEntityPositionSyncPacketto viewers. -
synchronizeNextTick
public void synchronizeNextTick()Asks for a position synchronization to happen during next entity tick. -
getSynchronizationTicks
public long getSynchronizationTicks()Returns the current synchronization interval. The default value isServerFlag.ENTITY_SYNCHRONIZATION_TICKSbut can be overridden per entity withsetSynchronizationTicks(long).- Returns:
- The current synchronization ticks
-
setSynchronizationTicks
public void setSynchronizationTicks(long ticks) Set the tick period until this entity's position is synchronized.- Parameters:
ticks- the new synchronization tick period
-
asHoverEvent
- Specified by:
asHoverEventin interfaceHoverEventSource<HoverEvent.ShowEntity>
-
tagHandler
- Specified by:
tagHandlerin interfaceTaggable
-
scheduler
- Specified by:
schedulerin interfaceSchedulable
-
updateSnapshot
Description copied from interface:SnapshotableUpdates the currently cached snapshot if required. The updater can be used to retrieve references to other snapshots while avoiding circular dependency. Be careful to do not storeupdateranywhere as its data will change when building requested references.This method is not thread-safe, and targeted at internal use since its execution rely on safe-points (e.g. end of ticks)
- Specified by:
updateSnapshotin interfaceSnapshotable- Parameters:
updater- the snapshot updater/context- Returns:
- the updated snapshot
-
eventNode
- Specified by:
eventNodein interfaceEventHandler<EntityEvent>
-
takeKnockback
public void takeKnockback(float strength, double x, double z) Applies knockback to the entity- Parameters:
strength- the strength of the knockback, 0.4 is the vanilla value for a bare hand hitx- knockback on x axle, for default knockback use the following formulasin(attacker.yaw * (pi/180))
z- knockback on z axle, for default knockback use the following formula-cos(attacker.yaw * (pi/180))
-
getLineOfSight
-
hasLineOfSight
Raycasts current entity's eye position to target eye position.- Parameters:
entity- the entity to be checked.exactView- if set to TRUE, checks whether target is IN the line of sight of the current one; otherwise checks if the current entity can rotate so that target will be in its line of sight.- Returns:
- true if the ray reaches the target bounding box before hitting a block.
-
hasLineOfSight
- Parameters:
entity- the entity to be checked.- Returns:
- if the current entity has line of sight to the given one.
- See Also:
-
getLineOfSightEntity
Gets first entity on the line of sight of the current one that matches the given predicate.- Parameters:
range- max length of the line of sight of the current entity to be checked.predicate- optional predicate- Returns:
- resulting entity whether there're any, null otherwise.
-
isOccluded
- Specified by:
isOccludedin interfaceShape
-
intersectBox
Description copied from interface:ShapeChecks if two bounding boxes intersect.- Specified by:
intersectBoxin interfaceShape- Parameters:
positionRelative- Relative position of bounding box to check withboundingBox- Bounding box to check for intersections with- Returns:
- is an intersection found
-
intersectBoxSwept
public boolean intersectBoxSwept(Point rayStart, Point rayDirection, Point shapePos, BoundingBox moving, SweepResult finalResult) Description copied from interface:ShapeChecks if a moving bounding box will hit this shape.- Specified by:
intersectBoxSweptin interfaceShape- Parameters:
rayStart- Position of the moving shaperayDirection- Movement vectorshapePos- Position of this shapemoving- Bounding Box of moving shapefinalResult- Stores final SweepResult- Returns:
- is an intersection found
-
relativeStart
Description copied from interface:ShapeRelative Start- Specified by:
relativeStartin interfaceShape- Returns:
- Start of shape
-
relativeEnd
Description copied from interface:ShapeRelative End- Specified by:
relativeEndin interfaceShape- Returns:
- End of shape
-
hasEntityCollision
public boolean hasEntityCollision() -
preventBlockPlacement
public boolean preventBlockPlacement() -
updateCollisions
protected void updateCollisions() -
getAcquirable
Deprecated.It's preferred to useAcquirableSource.acquirable()instead, as it is overridden by subclassesAcquires this entity.- Type Parameters:
T- the type of object to be acquired- Returns:
- the acquirable for this entity
-
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>- Returns:
- an Acquirable which can be used to synchronize access to this object
-
identity
- Specified by:
identityin interfaceIdentified
-
pointers
-
AcquirableSource.acquirable()instead, as it is overridden by subclasses