Package org.geysermc.connector.entity
Class Entity
java.lang.Object
org.geysermc.connector.entity.Entity
- Direct Known Subclasses:
AbstractArrowEntity,AreaEffectCloudEntity,BoatEntity,EnderCrystalEntity,EnderDragonPartEntity,ExpOrbEntity,FallingBlockEntity,FireworkEntity,ItemFrameEntity,LeashKnotEntity,LivingEntity,MinecartEntity,PaintingEntity,ThrowableEntity,TNTEntity
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected EntityTypeprotected longprotected com.nukkitx.protocol.bedrock.data.entity.EntityDataMapprotected com.nukkitx.math.vector.Vector3fprotected booleanSaves if the entity should be on the ground.protected it.unimi.dsi.fastutil.longs.LongOpenHashSetprotected com.nukkitx.math.vector.Vector3fprotected com.nukkitx.math.vector.Vector3fx = Yaw, y = Pitch, z = HeadYawprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionEntity(long entityId, long geyserId, EntityType entityType, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f motion, com.nukkitx.math.vector.Vector3f rotation) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalSpawnData(com.nukkitx.protocol.bedrock.packet.AddEntityPacket addEntityPacket)To be overridden in other entity classes, if additional things need to be done to the spawn entity packet.<I extends Entity>
IbooleandespawnEntity(GeyserSession session)Despawns the entitycom.nukkitx.math.vector.Vector3fx = Pitch, y = HeadYaw, z = Yawprotected int<I extends Entity>
booleanprotected booleanisShaking(GeyserSession session)If true, the entity should be shaking on the client's end.voidmoveAbsolute(GeyserSession session, com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported)voidmoveAbsolute(GeyserSession session, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f rotation, boolean isOnGround, boolean teleported)voidmoveRelative(GeyserSession session, double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround)voidmoveRelative(GeyserSession session, double relX, double relY, double relZ, com.nukkitx.math.vector.Vector3f rotation, boolean isOnGround)protected voidsetAir(int amount)Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles leftprotected voidsetDimensions(com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose pose)Set the height and width of the entity's bounding boxprotected voidsetDisplayName(GeyserSession session, net.kyori.adventure.text.Component name)protected voidsetDisplayNameVisible(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata entityMetadata)protected voidsetFreezing(GeyserSession session, float amount)Set a float from 0-1 - how strong the "frozen" overlay should be on screen.protected voidsetInvisible(GeyserSession session, boolean value)Set a boolean - whether the entity is invisible or visiblevoidspawnEntity(GeyserSession session)voidteleport(GeyserSession session, com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)Teleports an entity to a new location.voidupdateBedrockMetadata(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata entityMetadata, GeyserSession session)Applies the Java metadata to the local Bedrock metadata copyvoidupdateBedrockMetadata(GeyserSession session)Sends the Bedrock metadata to the clientvoidupdateHeadLookRotation(GeyserSession session, float headYaw)Updates an entity's head position.voidupdatePositionAndRotation(GeyserSession session, double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround)Updates an entity's position and rotation.voidupdateRotation(GeyserSession session, float yaw, float pitch, boolean isOnGround)Updates an entity's rotation.
-
Field Details
-
entityId
protected long entityId -
geyserId
protected final long geyserId -
position
protected com.nukkitx.math.vector.Vector3f position -
motion
protected com.nukkitx.math.vector.Vector3f motion -
rotation
protected com.nukkitx.math.vector.Vector3f rotationx = Yaw, y = Pitch, z = HeadYaw -
onGround
protected boolean onGroundSaves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
entityType
-
valid
protected boolean valid -
passengers
protected it.unimi.dsi.fastutil.longs.LongOpenHashSet passengers -
metadata
protected com.nukkitx.protocol.bedrock.data.entity.EntityDataMap metadata
-
-
Constructor Details
-
Entity
public Entity(long entityId, long geyserId, EntityType entityType, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f motion, com.nukkitx.math.vector.Vector3f rotation)
-
-
Method Details
-
spawnEntity
-
addAdditionalSpawnData
public void addAdditionalSpawnData(com.nukkitx.protocol.bedrock.packet.AddEntityPacket addEntityPacket)To be overridden in other entity classes, if additional things need to be done to the spawn entity packet. -
despawnEntity
Despawns the entity- Parameters:
session- The GeyserSession- Returns:
- can be deleted
-
moveRelative
public void moveRelative(GeyserSession session, double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround) -
moveRelative
public void moveRelative(GeyserSession session, double relX, double relY, double relZ, com.nukkitx.math.vector.Vector3f rotation, boolean isOnGround) -
moveAbsolute
public void moveAbsolute(GeyserSession session, com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported) -
moveAbsolute
public void moveAbsolute(GeyserSession session, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f rotation, boolean isOnGround, boolean teleported) -
teleport
public void teleport(GeyserSession session, com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)Teleports an entity to a new location. Used in JavaEntityTeleportTranslator.- Parameters:
session- GeyserSession.position- The new position of the entity.yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
updateHeadLookRotation
Updates an entity's head position. Used in JavaEntityHeadLookTranslator.- Parameters:
session- GeyserSession.headYaw- The new head rotation of the entity.
-
updatePositionAndRotation
public void updatePositionAndRotation(GeyserSession session, double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround)Updates an entity's position and rotation. Used in JavaEntityPositionRotationTranslator.- Parameters:
session- GeyserSessionmoveX- The new X offset of the current position.moveY- The new Y offset of the current position.moveZ- The new Z offset of the current position.yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
updateRotation
Updates an entity's rotation. Used in JavaEntityRotationTranslator.- Parameters:
session- GeyserSession.yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
updateBedrockMetadata
public void updateBedrockMetadata(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata entityMetadata, GeyserSession session)Applies the Java metadata to the local Bedrock metadata copy- Parameters:
entityMetadata- the Java entity metadatasession- GeyserSession
-
updateBedrockMetadata
Sends the Bedrock metadata to the client- Parameters:
session- GeyserSession
-
isShaking
If true, the entity should be shaking on the client's end.- Returns:
- whether
EntityFlag.SHAKINGshould be set to true.
-
setDisplayName
-
setDisplayNameVisible
protected void setDisplayNameVisible(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata entityMetadata) -
setDimensions
protected void setDimensions(com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose pose)Set the height and width of the entity's bounding box -
setFreezing
Set a float from 0-1 - how strong the "frozen" overlay should be on screen. -
setAir
protected void setAir(int amount)Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles left- Parameters:
amount- the amount of air
-
getMaxAir
protected int getMaxAir() -
setInvisible
Set a boolean - whether the entity is invisible or visible- Parameters:
session- the Geyser sessionvalue- true if the entity is invisible
-
getBedrockRotation
public com.nukkitx.math.vector.Vector3f getBedrockRotation()x = Pitch, y = HeadYaw, z = Yaw- Returns:
- the bedrock rotation
-
as
-
is
-