Class SessionPlayerEntity

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

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

    • initializeMetadata

      protected void initializeMetadata()
      Description copied from class: Entity
      Called on entity spawn. Used to populate the entity metadata and flags with default values.
      Overrides:
      initializeMetadata in class PlayerEntity
    • setClientSideSilent

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

      public void spawnEntity()
      Overrides:
      spawnEntity in class AvatarEntity
    • setYaw

      public void setYaw(float yaw)
      Description copied from class: Entity
      x = Yaw, y = Pitch, z = HeadYaw Java: Y = Yaw, X = Pitch
      Overrides:
      setYaw in class Entity
    • bedrockPosition

      public org.cloudburstmc.math.vector.Vector3f bedrockPosition()
      Description copied from class: Entity
      Gets the Bedrock edition position with the offset applied
      Overrides:
      bedrockPosition in class Entity
    • moveRelativeRaw

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

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

      public void updateHeadLookRotation(float headYaw)
      Description copied from class: Entity
      Updates an entity's head position. Used in JavaRotateHeadTranslator.
      Overrides:
      updateHeadLookRotation in class Entity
      Parameters:
      headYaw - The new head rotation of the entity.
    • 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
    • setPositionFromBedrockPos

      public void setPositionFromBedrockPos(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
    • setSneaking

      protected void setSneaking(boolean value)
      Overrides:
      setSneaking in class Entity
    • setAttributeScale

      protected void setAttributeScale(float scale)
      Overrides:
      setAttributeScale in class LivingEntity
    • 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 AvatarEntity
    • setPitch

      public void setPitch(float pitch)
      Overrides:
      setPitch in class AvatarEntity
    • 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
    • hasEnderEye

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

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

      protected boolean hasChargedProjectiles()
      Overrides:
      hasChargedProjectiles 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
    • attributeOrDefault

      public float attributeOrDefault(GeyserAttributeType type)
      This will ONLY include attributes that have a Bedrock equivalent!!! see LivingEntity.updateAttribute(Attribute, List)
    • 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
    • setLivingEntityFlags

      public void setLivingEntityFlags(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata entityMetadata)
      Overrides:
      setLivingEntityFlags in class LivingEntity
    • 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)
    • setVehicle

      public void setVehicle(Entity entity)
      Overrides:
      setVehicle in class Entity
    • getJumpVelocity

      public float getJumpVelocity()
      Used to calculate player jumping velocity for ground status calculation.
    • isOnClimbableBlock

      public boolean isOnClimbableBlock()
    • canStartGliding

      public boolean canStartGliding()
    • forceFlagUpdate

      public void forceFlagUpdate()
    • isGliding

      public boolean isGliding()
    • 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 attributes
    • getMiningEfficiency

      public double getMiningEfficiency()
    • getBlockBreakSpeed

      public double getBlockBreakSpeed()
    • getSubmergedMiningSpeed

      public double getSubmergedMiningSpeed()
    • 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
    • isInsideScaffolding

      public boolean isInsideScaffolding()
    • setInsideScaffolding

      public void setInsideScaffolding(boolean insideScaffolding)
    • getLastTickEndVelocity

      public org.cloudburstmc.math.vector.Vector3f getLastTickEndVelocity()
      The client last tick end velocity, used for calculating player onGround.
    • setLastTickEndVelocity

      public void setLastTickEndVelocity(org.cloudburstmc.math.vector.Vector3f lastTickEndVelocity)
      The client last tick end velocity, used for calculating player onGround.
    • getBedrockInteractRotation

      public org.cloudburstmc.math.vector.Vector2f getBedrockInteractRotation()
      The client claimed interact rotation, intended for touch (pocket) user.
    • setBedrockInteractRotation

      public void setBedrockInteractRotation(org.cloudburstmc.math.vector.Vector2f bedrockInteractRotation)
      The client claimed interact rotation, intended for touch (pocket) user.
    • getJavaYaw

      public float getJavaYaw()
    • setJavaYaw

      public void setJavaYaw(float javaYaw)
    • isCollidingVertically

      public boolean isCollidingVertically()
      If the player is colliding on the vertical axis or not according to the client.
    • setCollidingVertically

      public void setCollidingVertically(boolean collidingVertically)
      If the player is colliding on the vertical axis or not according to the client.
    • getRemovedPlayerVehicleId

      public @Nullable Integer getRemovedPlayerVehicleId()
      The vehicle that player was previously in before it got removed from the world.
    • setRemovedPlayerVehicleId

      public void setRemovedPlayerVehicleId(@Nullable Integer removedPlayerVehicleId)
      The vehicle that player was previously in before it got removed from the world.
    • getPendingBedInteraction

      public @Nullable SessionPlayerEntity.PendingBedInteraction getPendingBedInteraction()
      Vanilla Java, as of at least 26.3, always teleports the player to the centre of the bed head when the player interacts with a bed to sleep.

      When translating this teleport to Bedrock, the Bedrock client will step out of the bed and wake up. This results in the client being unable to sleep, as it will always be "kicked out" again by the server.

      To fix this, Geyser will have to silently ignore this teleport. However, as this teleport (as of 26.3) is sent before any other indicators that the player is actually sleeping (like occupied block state, or bed position metadata, etc.), the only way to recognise this teleport is by matching the position and motion with what would be expected from a bed interaction.

      This field serves that purpose: it is set by BedrockInventoryTransactionTranslator when interacting with a bed, and queried by JavaPlayerPositionTranslator when translating teleports. If a teleport does not match what would be expected after a bed interaction, it'll be processed as normal, and this field will be cleared.

      See Also:
    • setPendingBedInteraction

      public void setPendingBedInteraction(@Nullable SessionPlayerEntity.PendingBedInteraction pendingBedInteraction)
      Vanilla Java, as of at least 26.3, always teleports the player to the centre of the bed head when the player interacts with a bed to sleep.

      When translating this teleport to Bedrock, the Bedrock client will step out of the bed and wake up. This results in the client being unable to sleep, as it will always be "kicked out" again by the server.

      To fix this, Geyser will have to silently ignore this teleport. However, as this teleport (as of 26.3) is sent before any other indicators that the player is actually sleeping (like occupied block state, or bed position metadata, etc.), the only way to recognise this teleport is by matching the position and motion with what would be expected from a bed interaction.

      This field serves that purpose: it is set by BedrockInventoryTransactionTranslator when interacting with a bed, and queried by JavaPlayerPositionTranslator when translating teleports. If a teleport does not match what would be expected after a bed interaction, it'll be processed as normal, and this field will be cleared.

      See Also: