Class SessionPlayerEntity

All Implemented Interfaces:
org.geysermc.geyser.api.entity.type.GeyserEntity, org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity

public class SessionPlayerEntity extends PlayerEntity
The entity class specifically for a GeyserSession's player.
  • Field Details

    • attributes

      protected final Map<GeyserAttributeType,org.cloudburstmc.protocol.bedrock.data.AttributeData> attributes
      Used to fix some inconsistencies, especially in respawning.
  • Constructor Details

    • SessionPlayerEntity

      public SessionPlayerEntity(GeyserSession session)
  • Method Details

    • setClientSideSilent

      protected void setClientSideSilent()
      Overrides:
      setClientSideSilent in class Entity
    • spawnEntity

      public void spawnEntity()
      Overrides:
      spawnEntity in class PlayerEntity
    • moveRelative

      public void moveRelative(double relX, double relY, double relZ, float yaw, float pitch, float headYaw, boolean isOnGround)
      Overrides:
      moveRelative in class PlayerEntity
    • moveAbsolute

      public void moveAbsolute(org.cloudburstmc.math.vector.Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported)
      Overrides:
      moveAbsolute in class PlayerEntity
    • setPosition

      public void setPosition(org.cloudburstmc.math.vector.Vector3f position)
      Overrides:
      setPosition in class PlayerEntity
    • updateOwnRotation

      public void updateOwnRotation(float yaw, float pitch, float headYaw)
      Special method used only when updating the session player's rotation. For some reason, Mode#NORMAL ignored rotation. Yay.
      Parameters:
      yaw - the new yaw
      pitch - the new pitch
      headYaw - the head yaw
    • setPositionManual

      public void setPositionManual(org.cloudburstmc.math.vector.Vector3f position)
      Set the player's position without applying an offset or moving the bounding box This is used in BedrockMovePlayer which receives the player's position with the offset pre-applied
      Parameters:
      position - the new position of the Bedrock player
    • setFlags

      public void setFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata)
      Sending any updated flags (sprinting, onFire, etc.) to the client while in spectator is not needed Also "fixes" issue 3318
      Overrides:
      setFlags in class Entity
    • updateBoundingBox

      public void updateBoundingBox()
      Since 1.19.40, the client must be re-informed of its bounding box on respawn See issue 3370
    • setBoundingBoxHeight

      public boolean setBoundingBoxHeight(float height)
      Overrides:
      setBoundingBoxHeight in class LivingEntity
    • setPose

      public void setPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose)
      Description copied from class: Entity
      Usually used for bounding box and not animation.
      Overrides:
      setPose in class Entity
    • getMaxHealth

      public float getMaxHealth()
    • getHealth

      public float getHealth()
    • setHealth

      public void setHealth(float health)
    • setAirSupply

      protected void setAirSupply(int amount)
      Overrides:
      setAirSupply in class Entity
    • setRiderSeatPosition

      public void setRiderSeatPosition(org.cloudburstmc.math.vector.Vector3f position)
      Overrides:
      setRiderSeatPosition in class Entity
    • createHealthAttribute

      public org.cloudburstmc.protocol.bedrock.data.AttributeData createHealthAttribute()
      Overrides:
      createHealthAttribute in class LivingEntity
      Returns:
      a Bedrock health attribute constructed from the data sent from the server
    • hasShield

      protected boolean hasShield(boolean offhand)
      Overrides:
      hasShield in class LivingEntity
    • updateAttribute

      protected void updateAttribute(org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute javaAttribute, List<org.cloudburstmc.protocol.bedrock.data.AttributeData> newAttributes)
      Description copied from class: LivingEntity
      Takes the Java attribute and adds it to newAttributes as a Bedrock-formatted attribute
      Overrides:
      updateAttribute in class LivingEntity
    • calculateAttribute

      protected org.cloudburstmc.protocol.bedrock.data.AttributeData calculateAttribute(org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.Attribute javaAttribute, GeyserAttributeType type)
      Description copied from class: LivingEntity
      Calculates the complete attribute value to send to Bedrock. Will be overriden if attributes need to be cached.
      Overrides:
      calculateAttribute in class LivingEntity
    • setLastDeathPosition

      public void setLastDeathPosition(@Nullable org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.GlobalPos pos)
    • getTabListUuid

      public UUID getTabListUuid()
      Overrides:
      getTabListUuid in class PlayerEntity
      Returns:
      the UUID that should be used when dealing with Bedrock's tab list.
    • setAbsorptionHearts

      public void setAbsorptionHearts(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata entityMetadata)
      Overrides:
      setAbsorptionHearts in class PlayerEntity
    • resetMetadata

      public void resetMetadata()
      Overrides:
      resetMetadata in class PlayerEntity
    • resetAttributes

      public void resetAttributes()
    • resetAir

      public void resetAir()
    • setVehicleInput

      public void setVehicleInput(org.cloudburstmc.math.vector.Vector2f vehicleInput)
    • setVehicleJumpStrength

      public void setVehicleJumpStrength(int vehicleJumpStrength)
    • voidFloorPosition

      public int voidFloorPosition()
    • teleportVoidFloorFix

      public void teleportVoidFloorFix(boolean up)
      This method handles teleporting the player below or above the Bedrock void floor. The Java server should never see this desync as we adjust the position that we send to it
      Parameters:
      up - in which direction to teleport - true to resync our position, or false to be teleported below the void floor.
    • getAttributes

      public Map<GeyserAttributeType,org.cloudburstmc.protocol.bedrock.data.AttributeData> getAttributes()
      Used to fix some inconsistencies, especially in respawning.
    • getBlockInteractionRange

      public double getBlockInteractionRange()
      Java-only attribute
    • isRidingInFront

      public boolean isRidingInFront()
      Used in PlayerInputTranslator for movement checks.
    • getVehicleInput

      public org.cloudburstmc.math.vector.Vector2f getVehicleInput()
      Used when emulating client-side vehicles
    • getVehicleJumpStrength

      public int getVehicleJumpStrength()
      Used when emulating client-side vehicles
    • isVoidPositionDesynched

      public boolean isVoidPositionDesynched()
      Determines if our position is currently out-of-sync with the Java server due to our workaround for the void floor

      Must be reset when dying, switching worlds, or being teleported out of the void

    • setVoidPositionDesynched

      public void setVoidPositionDesynched(boolean voidPositionDesynched)
      Determines if our position is currently out-of-sync with the Java server due to our workaround for the void floor

      Must be reset when dying, switching worlds, or being teleported out of the void