Class Entity

java.lang.Object
org.geysermc.geyser.entity.type.Entity
All Implemented Interfaces:
org.geysermc.geyser.api.entity.type.GeyserEntity
Direct Known Subclasses:
AreaEffectCloudEntity, BoatEntity, DisplayBaseEntity, EnderCrystalEntity, EnderDragonPartEntity, EnderEyeEntity, EvokerFangsEntity, ExpOrbEntity, FallingBlockEntity, FireworkEntity, HangingEntity, InteractionEntity, LeashKnotEntity, LightningEntity, LivingEntity, MinecartEntity, ProjectileEntity, TNTEntity

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

    • session

      protected final GeyserSession session
    • bedrockDefinition

      protected BedrockEntityDefinition bedrockDefinition
    • javaTypeDefinition

      protected EntityTypeDefinition<?> javaTypeDefinition
    • 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
    • customNameVisible

      protected boolean customNameVisible
    • position

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

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

      protected float offset
    • 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
    • valid

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

      protected @Nullable String customName
    • 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.
    • metadata

      protected final Map<org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType<?>,Object> metadata
      A container storing all current metadata for an entity.
    • flags

      protected final EnumMap<org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag,Boolean> 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.
    • scale

      protected float scale
    • propertyManager

      protected final @Nullable GeyserEntityPropertyManager propertyManager
  • Constructor Details

  • 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, float headYaw, boolean isOnGround)
    • moveRelativeRaw

      public void moveRelativeRaw(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)
    • moveAbsoluteRaw

      public void moveAbsoluteRaw(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()
    • setCustomName

      public void setCustomName(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 applyTeamStyling)
    • setNameEntityData

      protected void setNameEntityData(String nametag)
    • updateNametag

      public void updateNametag(@Nullable Team team)
    • updateNametag

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

      protected void scoreVisibility(boolean show)
    • getDisplayName

      public @Nullable String getDisplayName(boolean includeStandardName)
    • setCustomNameVisible

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

      public void setNametagAlwaysShow(boolean value)
    • 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)
    • getBoundingBoxHeight

      public float getBoundingBoxHeight()
    • getBoundingBoxWidth

      public float getBoundingBoxWidth()
    • setCustomBoundingBoxWidth

      public void setCustomBoundingBoxWidth(float width)
    • setCustomBoundingBoxHeight

      public void setCustomBoundingBoxHeight(float height)
    • setScale

      public void setScale(float scale)
    • applyScale

      protected void applyScale()
    • 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.
    • doesJumpDismount

      public boolean doesJumpDismount()
      If true, the entity can be dismounted by pressing jump.
      Returns:
      whether the entity can be dismounted when pressing jump.
    • bedrockRotation

      public org.cloudburstmc.math.vector.Vector3f bedrockRotation()
      x = Pitch, y = Yaw, z = HeadYaw
      Returns:
      the bedrock rotation
    • bedrockPosition

      public org.cloudburstmc.math.vector.Vector3f bedrockPosition()
      Gets the Bedrock edition position with the offset applied
    • 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.
    • updatePropertiesBatched

      public void updatePropertiesBatched(Consumer<org.geysermc.geyser.api.entity.property.BatchPropertyUpdater> consumer, boolean immediate)
      Specified by:
      updatePropertiesBatched in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • offset

      public void offset(float offset, boolean teleport)
    • definition

      public @NonNull org.geysermc.geyser.api.entity.definition.GeyserEntityDefinition definition()
      Specified by:
      definition in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • position

      public @NonNull org.cloudburstmc.math.vector.Vector3f position()
      Specified by:
      position in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • update

      public <T> void update(@NonNull org.geysermc.geyser.api.entity.data.GeyserEntityDataType<T> dataType, @Nullable T value)
      Specified by:
      update in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • value

      public <T> T value(@NonNull org.geysermc.geyser.api.entity.data.GeyserEntityDataType<T> dataType)
      Specified by:
      value in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • getSession

      public GeyserSession getSession()
    • bedrockDefinition

      public BedrockEntityDefinition bedrockDefinition()
    • getJavaTypeDefinition

      public EntityTypeDefinition<?> getJavaTypeDefinition()
    • getEntityId

      public int getEntityId()
    • geyserId

      public long geyserId()
      Specified by:
      geyserId in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • uuid

      public UUID uuid()
      Specified by:
      uuid in interface org.geysermc.geyser.api.entity.type.GeyserEntity
    • getNametag

      public String getNametag()
      Do not call this setter directly! This will bypass the scoreboard and setting the metadata
    • isCustomNameVisible

      public boolean isCustomNameVisible()
    • getPosition

      public org.cloudburstmc.math.vector.Vector3f getPosition()
    • getMotion

      public org.cloudburstmc.math.vector.Vector3f getMotion()
    • getOffset

      public float getOffset()
    • 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
    • isValid

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

      public boolean isSilent()
    • getCustomBoundingBoxHeight

      public Float getCustomBoundingBoxHeight()
    • getCustomBoundingBoxWidth

      public Float getCustomBoundingBoxWidth()
    • 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.
    • getMetadata

      public Map<org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType<?>,Object> getMetadata()
      A container storing all current metadata for an entity.
    • getScale

      public float getScale()
    • getPropertyManager

      public @Nullable GeyserEntityPropertyManager getPropertyManager()
    • bedrockDefinition

      public Entity bedrockDefinition(BedrockEntityDefinition bedrockDefinition)
      Returns:
      this.
    • setJavaTypeDefinition

      public void setJavaTypeDefinition(EntityTypeDefinition<?> javaTypeDefinition)
    • setEntityId

      public void setEntityId(int entityId)
    • uuid

      public Entity uuid(UUID uuid)
      Returns:
      this.
    • setPosition

      public void setPosition(org.cloudburstmc.math.vector.Vector3f position)
    • setMotion

      public void setMotion(org.cloudburstmc.math.vector.Vector3f motion)
    • setOffset

      public void setOffset(float offset)
    • 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
    • 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.