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

public class Entity extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
     
    protected EntityType
     
    protected long
     
    protected com.nukkitx.protocol.bedrock.data.entity.EntityDataMap
     
    protected com.nukkitx.math.vector.Vector3f
     
    protected boolean
    Saves if the entity should be on the ground.
    protected it.unimi.dsi.fastutil.longs.LongOpenHashSet
     
    protected com.nukkitx.math.vector.Vector3f
     
    protected com.nukkitx.math.vector.Vector3f
    x = Yaw, y = Pitch, z = HeadYaw
    protected boolean
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    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.
    <I extends Entity>
    I
    as​(Class<I> entityClass)
     
    boolean
    Despawns the entity
    com.nukkitx.math.vector.Vector3f
    x = Pitch, y = HeadYaw, z = Yaw
    protected int
     
    <I extends Entity>
    boolean
    is​(Class<I> entityClass)
     
    protected boolean
    If true, the entity should be shaking on the client's end.
    void
    moveAbsolute​(GeyserSession session, com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported)
     
    void
    moveAbsolute​(GeyserSession session, com.nukkitx.math.vector.Vector3f position, com.nukkitx.math.vector.Vector3f rotation, boolean isOnGround, boolean teleported)
     
    void
    moveRelative​(GeyserSession session, double relX, double relY, double relZ, float yaw, float pitch, boolean isOnGround)
     
    void
    moveRelative​(GeyserSession session, double relX, double relY, double relZ, com.nukkitx.math.vector.Vector3f rotation, boolean isOnGround)
     
    protected void
    setAir​(int amount)
    Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles left
    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
    protected String
    setDisplayName​(GeyserSession session, net.kyori.adventure.text.Component name)
     
    protected void
    setFreezing​(GeyserSession session, float amount)
    Set a float from 0-1 - how strong the "frozen" overlay should be on screen.
    protected void
    setInvisible​(GeyserSession session, boolean value)
    Set a boolean - whether the entity is invisible or visible
    void
     
    void
    teleport​(GeyserSession session, com.nukkitx.math.vector.Vector3f position, float yaw, float pitch, boolean isOnGround)
    Teleports an entity to a new location.
    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
    void
    Sends the Bedrock metadata to the client
    void
    updateHeadLookRotation​(GeyserSession session, float headYaw)
    Updates an entity's head position.
    void
    updatePositionAndRotation​(GeyserSession session, double moveX, double moveY, double moveZ, float yaw, float pitch, boolean isOnGround)
    Updates an entity's position and rotation.
    void
    updateRotation​(GeyserSession session, 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

    • entityId

      protected long entityId
    • geyserId

      protected 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 rotation
      x = Yaw, y = Pitch, z = HeadYaw
    • onGround

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

      protected EntityType 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

      public void spawnEntity(GeyserSession session)
    • 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(GeyserSession session)
      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

      public void updateHeadLookRotation(GeyserSession session, float headYaw)
      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 - GeyserSession
      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(GeyserSession session, float yaw, float pitch, boolean isOnGround)
      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 metadata
      session - GeyserSession
    • updateBedrockMetadata

      public void updateBedrockMetadata(GeyserSession session)
      Sends the Bedrock metadata to the client
      Parameters:
      session - GeyserSession
    • isShaking

      protected boolean isShaking(GeyserSession session)
      If true, the entity should be shaking on the client's end.
      Returns:
      whether EntityFlag.SHAKING should be set to true.
    • setDisplayName

      protected String setDisplayName(GeyserSession session, net.kyori.adventure.text.Component name)
      Returns:
      the translated string display
    • 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

      protected void setFreezing(GeyserSession session, float amount)
      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

      protected void setInvisible(GeyserSession session, boolean value)
      Set a boolean - whether the entity is invisible or visible
      Parameters:
      session - the Geyser session
      value - 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

      public <I extends Entity> I as(Class<I> entityClass)
    • is

      public <I extends Entity> boolean is(Class<I> entityClass)