Package org.geysermc.geyser.entity.type
Class Entity
java.lang.Object
org.geysermc.geyser.entity.type.Entity
- Direct Known Subclasses:
AbstractArrowEntity,AreaEffectCloudEntity,BoatEntity,EnderCrystalEntity,EnderDragonPartEntity,EvokerFangsEntity,ExpOrbEntity,FallingBlockEntity,FireworkEntity,ItemFrameEntity,LeashKnotEntity,LightningEntity,LivingEntity,MinecartEntity,PaintingEntity,ThrowableEntity,TNTEntity
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EntityDefinition<?>protected GeyserDirtyMetadataA container to store temporary metadata before it's sent to Bedrock.protected intprotected com.nukkitx.protocol.bedrock.data.entity.EntityFlagsThe entity flags for the Bedrock entity.protected longprotected floatprotected com.nukkitx.math.vector.Vector3fprotected Stringprotected booleanSaves if the entity should be on the ground.protected floatprotected com.nukkitx.math.vector.Vector3fprotected GeyserSessionprotected UUIDprotected booleanprotected Entityprotected floatx = Yaw, y = Pitch, z = HeadYaw -
Constructor Summary
ConstructorsConstructorDescriptionEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f motion, float yaw, float pitch, float headYaw) -
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>
IbooleanDespawns the entitycom.nukkitx.math.vector.Vector3fx = Pitch, y = HeadYaw, z = YawbooleangetFlag(com.nukkitx.protocol.bedrock.data.entity.EntityFlag flag)protected intprotected voidCalled on entity spawn.<I extends Entity>
booleanprotected booleanIf true, the entity should be shaking on the client's end.voidmoveAbsolute(com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported)voidmoveAbsolute(com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported)voidmoveRelative(double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround)voidmoveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround)voidsetAir(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata)Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles leftprotected voidsetAirSupply(int amount)voidsetBoundingBoxHeight(float height)voidsetBoundingBoxWidth(float width)protected voidsetDimensions(com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose pose)Set the height and width of the entity's bounding boxvoidsetDisplayName(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata<Optional<net.kyori.adventure.text.Component>,?> entityMetadata)voidsetDisplayNameVisible(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)voidsetFlag(com.nukkitx.protocol.bedrock.data.entity.EntityFlag flag, boolean value)Updates a flag value and determines if the flags would need synced with the Bedrock client.voidsetFlags(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata)floatsetFreezing(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata)Set a float from 0-1 - how strong the "frozen" overlay should be on screen.voidsetGravity(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)protected voidsetInvisible(boolean value)Set a boolean - whether the entity is invisible or visiblevoidsetPose(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata<com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose,?> entityMetadata)Usually used for bounding box and not animation.voidsetRiderSeatPosition(com.nukkitx.math.vector.Vector3f position)voidvoidteleport(com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)Teleports an entity to a new location.voidSends the Bedrock metadata to the clientvoidupdateHeadLookRotation(float headYaw)Updates an entity's head position.protected voidUpdate this entity's mount offsetprotected voidUpdate the mount offsets of each passenger on this vehiclevoidupdatePositionAndRotation(double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround)Updates an entity's position and rotation.voidupdateRotation(float yaw, float pitch, boolean isOnGround)Updates an entity's rotation.
-
Field Details
-
session
-
entityId
protected int entityId -
geyserId
protected final long geyserId -
uuid
-
position
protected com.nukkitx.math.vector.Vector3f position -
motion
protected com.nukkitx.math.vector.Vector3f motion -
yaw
protected float yawx = Yaw, y = Pitch, z = HeadYaw -
pitch
protected float pitch -
headYaw
protected float headYaw -
onGround
protected boolean onGroundSaves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
definition
-
valid
protected boolean valid -
nametag
-
passengers
-
vehicle
-
dirtyMetadata
A container to store temporary metadata before it's sent to Bedrock. -
flags
protected final com.nukkitx.protocol.bedrock.data.entity.EntityFlags flagsThe entity flags for the Bedrock entity. These must always be saved - if flags are updated and the other values aren't present, the Bedrock client will think they are set to false.
-
-
Constructor Details
-
Entity
public Entity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f motion, float yaw, float pitch, float headYaw)
-
-
Method Details
-
initializeMetadata
protected void initializeMetadata()Called on entity spawn. Used to populate the entity metadata and flags with default values. -
spawnEntity
public void 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
public boolean despawnEntity()Despawns the entity- Returns:
- can be deleted
-
moveRelative
public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround) -
moveRelative
public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround) -
moveAbsolute
public void moveAbsolute(com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported) -
moveAbsolute
public void moveAbsolute(com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) -
teleport
public void teleport(com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)Teleports an entity to a new location. Used in JavaTeleportEntityTranslator.- Parameters:
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
public void updateHeadLookRotation(float headYaw)Updates an entity's head position. Used in JavaRotateHeadTranslator.- Parameters:
headYaw- The new head rotation of the entity.
-
updatePositionAndRotation
public void updatePositionAndRotation(double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround)Updates an entity's position and rotation. Used in JavaMoveEntityPosRotTranslator.- Parameters:
moveX- 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
public void updateRotation(float yaw, float pitch, boolean isOnGround)Updates an entity's rotation. Used in JavaMoveEntityRotTranslator.- Parameters:
yaw- The new yaw of the entity.pitch- The new pitch of the entity.isOnGround- Whether the entity is currently on the ground.
-
getFlag
public final boolean getFlag(com.nukkitx.protocol.bedrock.data.entity.EntityFlag flag) -
setFlag
public final void setFlag(com.nukkitx.protocol.bedrock.data.entity.EntityFlag flag, boolean value)Updates a flag value and determines if the flags would need synced with the Bedrock client. -
updateBedrockMetadata
public void updateBedrockMetadata()Sends the Bedrock metadata to the client -
setFlags
public void setFlags(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata) -
setInvisible
protected void setInvisible(boolean value)Set a boolean - whether the entity is invisible or visible- Parameters:
value- true if the entity is invisible
-
setAir
public final void setAir(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata)Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles left -
setAirSupply
protected void setAirSupply(int amount) -
getMaxAir
protected int getMaxAir() -
setDisplayName
public void setDisplayName(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata<Optional<net.kyori.adventure.text.Component>,?> entityMetadata) -
setDisplayNameVisible
public void setDisplayNameVisible(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) -
setGravity
public void setGravity(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata) -
setPose
public void setPose(com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata<com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose,?> entityMetadata)Usually used for bounding box and not animation. -
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 -
setBoundingBoxHeight
public void setBoundingBoxHeight(float height) -
setBoundingBoxWidth
public void setBoundingBoxWidth(float width) -
setFreezing
public float setFreezing(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata)Set a float from 0-1 - how strong the "frozen" overlay should be on screen. -
setRiderSeatPosition
public void setRiderSeatPosition(com.nukkitx.math.vector.Vector3f position) -
isShaking
protected boolean isShaking()If true, the entity should be shaking on the client's end.- Returns:
- whether
EntityFlag.SHAKINGshould be set to true.
-
getBedrockRotation
public com.nukkitx.math.vector.Vector3f getBedrockRotation()x = Pitch, y = HeadYaw, z = Yaw- Returns:
- the bedrock rotation
-
updatePassengerOffsets
protected void updatePassengerOffsets()Update the mount offsets of each passenger on this vehicle -
updateMountOffset
protected void updateMountOffset()Update this entity's mount offset -
as
-
is
-