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, DisplayBaseEntity, EnderCrystalEntity, EnderDragonPartEntity, EnderEyeEntity, EvokerFangsEntity, ExpOrbEntity, FallingBlockEntity, FireworkEntity, HangingEntity, InteractionEntity, LeashKnotEntity, LightningEntity, LivingEntity, MinecartEntity, ThrowableEntity, TNTEntity

public class Entity extends Object implements org.geysermc.geyser.api.entity.type.GeyserEntity
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected EntityDefinition<?>
     
    protected final GeyserDirtyMetadata
    A container to store temporary metadata before it's sent to Bedrock.
    protected int
     
    protected final EnumSet<org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag>
    The entity flags for the Bedrock entity.
    protected final long
     
    protected float
     
    protected org.cloudburstmc.math.vector.Vector3f
     
    protected String
    Do not call this setter directly! This will bypass the scoreboard and setting the metadata
    protected boolean
    Saves if the entity should be on the ground.
    protected List<Entity>
     
    protected float
     
    protected org.cloudburstmc.math.vector.Vector3f
     
     
    protected final GeyserSession
     
    protected boolean
     
    protected UUID
     
    protected boolean
    Indicates if the entity has been initialized and spawned
    protected Entity
     
    protected float
    x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    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.
    void
    Despawns the entity
    org.cloudburstmc.math.vector.Vector3f
    x = Pitch, y = Yaw, z = HeadYaw
    float
     
    float
     
     
    A container to store temporary metadata before it's sent to Bedrock.
     
    int
     
    final boolean
    getFlag(org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag flag)
     
    long
     
    float
     
    protected short
     
    org.cloudburstmc.math.vector.Vector3f
     
    Do not call this setter directly! This will bypass the scoreboard and setting the metadata
     
    float
     
    org.cloudburstmc.math.vector.Vector3f
     
     
     
     
     
    float
    x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch
    boolean
     
    protected void
    Called on entity spawn.
    interact(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand)
    Simulates interacting with an entity.
    interactAt(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand)
    Simulates interacting with this entity at a specific click point.
    boolean
     
    boolean
    Saves if the entity should be on the ground.
    protected boolean
    If true, the entity should be shaking on the client's end.
    boolean
     
    boolean
    Indicates if the entity has been initialized and spawned
    int
     
    void
    moveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported)
     
    void
    moveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported)
     
    void
    moveRelative(double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround)
     
    void
    moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround)
     
    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.
    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.
    protected void
    scoreVisibility(boolean show)
     
    final void
    setAir(org.geysermc.mcprotocollib.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
    protected void
    setAirSupply(int amount)
     
    boolean
    setBoundingBoxHeight(float height)
     
    void
    setBoundingBoxWidth(float width)
     
    protected void
     
    void
     
    protected void
    setDimensionsFromPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose)
    Set the height and width of the entity's bounding box
    void
    setDisplayName(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata<Optional<net.kyori.adventure.text.Component>,?> entityMetadata)
     
    void
    setDisplayNameVisible(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)
     
    void
    setEntityId(int entityId)
     
    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.
    void
    setFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata)
     
    protected void
    setFlagsDirty(boolean flagsDirty)
    Indicates if flags have been updated and need to be sent to the client.
    float
    setFreezing(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata entityMetadata)
    Set a float from 0-1 - how strong the "frozen" overlay should be on screen.
    protected void
    setGliding(boolean value)
    Set a boolean - whether the entity is gliding
    void
    setGravity(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)
     
    void
    setHeadYaw(float headYaw)
     
    protected void
    setInvisible(boolean value)
    Set a boolean - whether the entity is invisible or visible
    void
    setMotion(org.cloudburstmc.math.vector.Vector3f motion)
     
    protected void
    setNametag(@Nullable String nametag, boolean fromDisplayName)
     
    void
    setOnGround(boolean onGround)
    Saves if the entity should be on the ground.
    void
    setPassengers(List<Entity> passengers)
     
    void
    setPitch(float pitch)
     
    void
    setPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose)
    Usually used for bounding box and not animation.
    void
    setPosition(org.cloudburstmc.math.vector.Vector3f position)
     
    void
    setRiderSeatPosition(org.cloudburstmc.math.vector.Vector3f position)
     
    final void
    setSilent(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)
     
    protected void
    setSneaking(boolean value)
     
    protected void
    setSprinting(boolean value)
     
    void
    setUuid(UUID uuid)
     
    void
    setValid(boolean valid)
    Indicates if the entity has been initialized and spawned
    void
    setVehicle(Entity vehicle)
     
    void
    setYaw(float yaw)
    x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch
    void
     
    protected String
     
     
    void
    teleport(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)
    Teleports an entity to a new location.
    protected InteractiveTag
    testInteraction(org.geysermc.mcprotocollib.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.
    void
    Sends the Bedrock entity properties to the client
    void
    Sends the Bedrock metadata to the client
    void
    updateHeadLookRotation(float headYaw)
    Updates an entity's head position.
    final void
    Update the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride")
    protected void
    Update this entity's mount offset
    void
    updateNametag(@Nullable Team team)
     
    protected void
    updateNametag(@Nullable Team team, boolean visible)
     
    protected void
    Update the mount offsets of each passenger on this vehicle
    void
    updatePositionAndRotation(double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround)
    Updates an entity's position and rotation.
    void
    updateRotation(float yaw, float pitch, boolean isOnGround)
    Updates an entity's rotation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • session

      protected final GeyserSession session
    • entityId

      protected int entityId
    • geyserId

      protected final long geyserId
    • uuid

      protected UUID uuid
    • nametag

      protected String nametag
      Do not call this setter directly! This will bypass the scoreboard and setting the metadata
    • position

      protected org.cloudburstmc.math.vector.Vector3f position
    • motion

      protected org.cloudburstmc.math.vector.Vector3f motion
    • yaw

      protected float yaw
      x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch
    • pitch

      protected float pitch
    • headYaw

      protected float headYaw
    • onGround

      protected boolean onGround
      Saves if the entity should be on the ground. Otherwise entities like parrots are flapping when rotating
    • definition

      protected EntityDefinition<?> definition
    • valid

      protected boolean valid
      Indicates if the entity has been initialized and spawned
    • silent

      protected boolean silent
    • passengers

      protected List<Entity> passengers
    • vehicle

      protected Entity vehicle
    • dirtyMetadata

      protected final GeyserDirtyMetadata dirtyMetadata
      A container to store temporary metadata before it's sent to Bedrock.
    • flags

      protected final EnumSet<org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag> 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.
    • propertyManager

      protected final GeyserEntityPropertyManager propertyManager
  • 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 void despawnEntity()
      Despawns the entity
    • 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
    • updateBedrockEntityProperties

      public void updateBedrockEntityProperties()
      Sends the Bedrock entity properties to the client
    • setFlags

      public void setFlags(org.geysermc.mcprotocollib.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
    • setGliding

      protected void setGliding(boolean value)
      Set a boolean - whether the entity is gliding
    • setSprinting

      protected void setSprinting(boolean value)
    • setSneaking

      protected void setSneaking(boolean value)
    • setAir

      public final void setAir(org.geysermc.mcprotocollib.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()
    • teamIdentifier

      public String teamIdentifier()
    • setDisplayName

      public void setDisplayName(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata<Optional<net.kyori.adventure.text.Component>,?> entityMetadata)
    • standardDisplayName

      protected String standardDisplayName()
    • setNametag

      protected void setNametag(@Nullable String nametag, boolean fromDisplayName)
    • updateNametag

      public void updateNametag(@Nullable Team team)
    • updateNametag

      protected void updateNametag(@Nullable Team team, boolean visible)
    • scoreVisibility

      protected void scoreVisibility(boolean show)
    • setDisplayNameVisible

      public void setDisplayNameVisible(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)
    • setSilent

      public final void setSilent(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)
    • setGravity

      public void setGravity(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata entityMetadata)
    • setPose

      public void setPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose)
      Usually used for bounding box and not animation.
    • setDimensionsFromPose

      protected void setDimensionsFromPose(org.geysermc.mcprotocollib.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(org.geysermc.mcprotocollib.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.SHAKING should 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:
      javaId in interface org.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(org.geysermc.mcprotocollib.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 mirror interact(Hand) without any side effects.
    • interact

      public InteractionResult interact(org.geysermc.mcprotocollib.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).
    • hasLeashesToDrop

      public boolean hasLeashesToDrop()
    • interactAt

      public InteractionResult interactAt(org.geysermc.mcprotocollib.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.
    • getSession

      public GeyserSession getSession()
    • getEntityId

      public int getEntityId()
    • getGeyserId

      public long getGeyserId()
    • getUuid

      public UUID getUuid()
    • getNametag

      public String getNametag()
      Do not call this setter directly! This will bypass the scoreboard and setting the metadata
    • 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 Java: Y = Yaw, X = Pitch
    • 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

      public EntityDefinition<?> getDefinition()
    • isValid

      public boolean isValid()
      Indicates if the entity has been initialized and spawned
    • getBoundingBoxHeight

      public float getBoundingBoxHeight()
    • getBoundingBoxWidth

      public float getBoundingBoxWidth()
    • getDisplayName

      public String getDisplayName()
    • isSilent

      public boolean isSilent()
    • getPassengers

      public List<Entity> getPassengers()
    • getVehicle

      public Entity getVehicle()
    • getDirtyMetadata

      public GeyserDirtyMetadata getDirtyMetadata()
      A container to store temporary metadata before it's sent to Bedrock.
    • getPropertyManager

      public GeyserEntityPropertyManager getPropertyManager()
    • setEntityId

      public void setEntityId(int entityId)
    • setUuid

      public void setUuid(UUID uuid)
    • 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 Java: Y = Yaw, X = Pitch
    • 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

      public void setDefinition(EntityDefinition<?> definition)
    • setValid

      public void setValid(boolean valid)
      Indicates if the entity has been initialized and spawned
    • setPassengers

      public void setPassengers(List<Entity> passengers)
    • setVehicle

      public void setVehicle(Entity vehicle)
    • setFlagsDirty

      protected void setFlagsDirty(boolean flagsDirty)
      Indicates if flags have been updated and need to be sent to the client.