Package org.geysermc.geyser.entity.type
Class Entity
java.lang.Object
org.geysermc.geyser.entity.type.Entity
- All Implemented Interfaces:
org.geysermc.geyser.api.entity.type.GeyserEntity
- Direct Known Subclasses:
AbstractArrowEntity,AreaEffectCloudEntity,BoatEntity,EnderCrystalEntity,EnderDragonPartEntity,EvokerFangsEntity,ExpOrbEntity,FallingBlockEntity,FireworkEntity,InteractionEntity,ItemFrameEntity,LeashKnotEntity,LightningEntity,LivingEntity,MinecartEntity,PaintingEntity,TextDisplayEntity,ThrowableEntity,TNTEntity
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EntityDefinition<?>protected GeyserDirtyMetadataA container to store temporary metadata before it's sent to Bedrock.protected intprotected EnumSet<org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag>The entity flags for the Bedrock entity.protected longprotected floatprotected org.cloudburstmc.math.vector.Vector3fprotected Stringprotected booleanSaves if the entity should be on the ground.protected floatprotected org.cloudburstmc.math.vector.Vector3fprotected GeyserSessionprotected booleanprotected UUIDprotected booleanIndicates if the entity has been initialized and spawnedprotected Entityprotected floatx = Yaw, y = Pitch, z = HeadYaw -
Constructor Summary
ConstructorsConstructorDescriptionEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, org.cloudburstmc.math.vector.Vector3f position, org.cloudburstmc.math.vector.Vector3f motion, float yaw, float pitch, float headYaw) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdditionalSpawnData(org.cloudburstmc.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 entityorg.cloudburstmc.math.vector.Vector3fx = Pitch, y = Yaw, z = HeadYawfloatfloatA container to store temporary metadata before it's sent to Bedrock.intbooleangetFlag(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag)longfloatprotected shortorg.cloudburstmc.math.vector.Vector3ffloatgetPitch()org.cloudburstmc.math.vector.Vector3fgetUuid()floatgetYaw()x = Yaw, y = Pitch, z = HeadYawprotected voidCalled on entity spawn.interact(com.github.steveice10.mc.protocol.data.game.entity.player.Hand hand)Simulates interacting with an entity.interactAt(com.github.steveice10.mc.protocol.data.game.entity.player.Hand hand)Simulates interacting with this entity at a specific click point.booleanisAlive()booleanSaves if the entity should be on the ground.protected booleanIf true, the entity should be shaking on the client's end.booleanisSilent()booleanisValid()Indicates if the entity has been initialized and spawnedintjavaId()voidmoveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported)voidmoveAbsolute(org.cloudburstmc.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)voidplayEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type)Send an entity event of the specified type to the Bedrock player from this entity.voidplayEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type, int data)Send an entity event of the specified type with the specified data to the Bedrock player from this entity.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)booleansetBoundingBoxHeight(float height)voidsetBoundingBoxWidth(float width)protected voidvoidsetDefinition(EntityDefinition<?> definition)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)voidsetEntityId(int entityId)voidsetFlag(org.cloudburstmc.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)protected voidsetFlagsDirty(boolean flagsDirty)Indicates if flags have been updated and need to be sent to the client.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)voidsetHeadYaw(float headYaw)protected voidsetInvisible(boolean value)Set a boolean - whether the entity is invisible or visiblevoidsetMotion(org.cloudburstmc.math.vector.Vector3f motion)voidsetOnGround(boolean onGround)Saves if the entity should be on the ground.voidsetPassengers(List<Entity> passengers)voidsetPitch(float pitch)voidsetPose(com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose pose)Usually used for bounding box and not animation.voidsetPosition(org.cloudburstmc.math.vector.Vector3f position)voidsetRiderSeatPosition(org.cloudburstmc.math.vector.Vector3f position)voidsetSilent(com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)voidvoidsetValid(boolean valid)Indicates if the entity has been initialized and spawnedvoidsetVehicle(Entity vehicle)voidsetYaw(float yaw)x = Yaw, y = Pitch, z = HeadYawvoidvoidteleport(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)Teleports an entity to a new location.protected InteractiveTagtestInteraction(com.github.steveice10.mc.protocol.data.game.entity.player.Hand hand)Test interacting with the given hand to see if we should send a tag to the Bedrock client.voidSends the Bedrock metadata to the clientvoidupdateHeadLookRotation(float headYaw)Updates an entity's head position.voidUpdate the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride")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 org.cloudburstmc.math.vector.Vector3f position -
motion
protected org.cloudburstmc.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 validIndicates if the entity has been initialized and spawned -
nametag
-
silent
protected boolean silent -
passengers
-
vehicle
-
dirtyMetadata
A container to store temporary metadata before it's sent to Bedrock. -
flags
The 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, org.cloudburstmc.math.vector.Vector3f position, org.cloudburstmc.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. -
setClientSideSilent
protected void setClientSideSilent() -
spawnEntity
public void spawnEntity() -
addAdditionalSpawnData
public void addAdditionalSpawnData(org.cloudburstmc.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(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported) -
moveAbsolute
public void moveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) -
teleport
public void teleport(org.cloudburstmc.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(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag) -
setFlag
public final void setFlag(org.cloudburstmc.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 short 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) -
setSilent
public final void setSilent(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.Pose pose)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 boolean 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(org.cloudburstmc.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 org.cloudburstmc.math.vector.Vector3f getBedrockRotation()x = Pitch, y = Yaw, z = HeadYaw- 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 -
javaId
public int javaId()- Specified by:
javaIdin interfaceorg.geysermc.geyser.api.entity.type.GeyserEntity
-
isAlive
public boolean isAlive() -
updateInteractiveTag
public final void updateInteractiveTag()Update the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride") -
testInteraction
protected InteractiveTag testInteraction(com.github.steveice10.mc.protocol.data.game.entity.player.Hand hand)Test interacting with the given hand to see if we should send a tag to the Bedrock client. Should usually mirrorinteract(Hand)without any side effects. -
interact
public InteractionResult interact(com.github.steveice10.mc.protocol.data.game.entity.player.Hand hand)Simulates interacting with an entity. The code here should mirror Java Edition code to the best of its ability, to ensure packet parity as well as functionality parity (such as sound effect responses). -
interactAt
public InteractionResult interactAt(com.github.steveice10.mc.protocol.data.game.entity.player.Hand hand)Simulates interacting with this entity at a specific click point. As of Java Edition 1.18.1, this is only used for armor stands. -
playEntityEvent
public final void playEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type)Send an entity event of the specified type to the Bedrock player from this entity. -
playEntityEvent
public final void playEntityEvent(org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType type, int data)Send an entity event of the specified type with the specified data to the Bedrock player from this entity. -
as
-
getSession
-
getEntityId
public int getEntityId() -
getGeyserId
public long getGeyserId() -
getUuid
-
getPosition
public org.cloudburstmc.math.vector.Vector3f getPosition() -
getMotion
public org.cloudburstmc.math.vector.Vector3f getMotion() -
getYaw
public float getYaw()x = Yaw, y = Pitch, z = HeadYaw -
getPitch
public float getPitch() -
getHeadYaw
public float getHeadYaw() -
isOnGround
public boolean isOnGround()Saves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
getDefinition
-
isValid
public boolean isValid()Indicates if the entity has been initialized and spawned -
getBoundingBoxHeight
public float getBoundingBoxHeight() -
getBoundingBoxWidth
public float getBoundingBoxWidth() -
getNametag
-
isSilent
public boolean isSilent() -
getPassengers
-
getVehicle
-
getDirtyMetadata
A container to store temporary metadata before it's sent to Bedrock. -
setEntityId
public void setEntityId(int entityId) -
setUuid
-
setPosition
public void setPosition(org.cloudburstmc.math.vector.Vector3f position) -
setMotion
public void setMotion(org.cloudburstmc.math.vector.Vector3f motion) -
setYaw
public void setYaw(float yaw)x = Yaw, y = Pitch, z = HeadYaw -
setPitch
public void setPitch(float pitch) -
setHeadYaw
public void setHeadYaw(float headYaw) -
setOnGround
public void setOnGround(boolean onGround)Saves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating -
setDefinition
-
setValid
public void setValid(boolean valid)Indicates if the entity has been initialized and spawned -
setPassengers
-
setVehicle
-
setFlagsDirty
protected void setFlagsDirty(boolean flagsDirty)Indicates if flags have been updated and need to be sent to the client.
-