Class CollisionManager

java.lang.Object
org.geysermc.geyser.level.physics.CollisionManager

public class CollisionManager extends Object
  • Field Details

    • COLLISION_TOLERANCE

      public static final double COLLISION_TOLERANCE
      Additional space where blocks are checked, which is helpful for fixing NoCheatPlus's Passable check. This check doesn't allow players right up against the block, so they must be pushed slightly away.
      See Also:
      Constant Field Values
  • Constructor Details

    • CollisionManager

      public CollisionManager(GeyserSession session)
  • Method Details

    • updatePlayerBoundingBox

      public void updatePlayerBoundingBox(com.nukkitx.math.vector.Vector3f position)
      Updates the stored bounding box
      Parameters:
      position - The new position of the player
    • updatePlayerBoundingBox

      public void updatePlayerBoundingBox(com.nukkitx.math.vector.Vector3d position)
      Updates the stored bounding box
      Parameters:
      position - The new position of the player
    • updatePlayerBoundingBox

      public void updatePlayerBoundingBox()
      Updates the height of the stored bounding box
    • adjustBedrockPosition

      public com.nukkitx.math.vector.Vector3d adjustBedrockPosition(com.nukkitx.math.vector.Vector3f bedrockPosition, boolean onGround, boolean teleported)
      Adjust the Bedrock position before sending to the Java server to account for inaccuracies in movement between the two versions. Will also send corrected movement packets back to Bedrock if they collide with pistons.
      Parameters:
      bedrockPosition - the current Bedrock position of the client
      onGround - whether the Bedrock player is on the ground
      teleported - whether the Bedrock player has teleported to a new position. If true, movement correction is skipped.
      Returns:
      the position to send to the Java server, or null to cancel sending the packet
    • recalculatePosition

      public void recalculatePosition()
    • collidableBlocksIterator

      public BlockPositionIterator collidableBlocksIterator(BoundingBox box)
    • playerCollidableBlocksIterator

      public BlockPositionIterator playerCollidableBlocksIterator()
    • correctPlayerPosition

      public boolean correctPlayerPosition()
      Returns false if the movement is invalid, and in this case it shouldn't be sent to the server and should be cancelled See BlockCollision.correctPosition(GeyserSession, int, int, int, BoundingBox) for more info
    • correctPlayerMovement

      public com.nukkitx.math.vector.Vector3d correctPlayerMovement(com.nukkitx.math.vector.Vector3d movement, boolean checkWorld, boolean teleported)
    • correctMovement

      public com.nukkitx.math.vector.Vector3d correctMovement(com.nukkitx.math.vector.Vector3d movement, BoundingBox boundingBox, boolean onGround, double stepUp, boolean checkWorld)
    • isUnderSlab

      public boolean isUnderSlab()
      Returns:
      true if the block located at the player's floor position plus 1 would intersect with the player, were they not sneaking
    • isPlayerInWater

      public boolean isPlayerInWater()
      Returns:
      if the player is currently in a water block
    • updateScaffoldingFlags

      public void updateScaffoldingFlags(boolean updateMetadata)
      Updates scaffolding entity flags Scaffolding needs to be checked per-move since it's a flag in Bedrock but Java does it client-side
      Parameters:
      updateMetadata - whether we should update metadata if something changed
    • getPlayerBoundingBox

      public BoundingBox getPlayerBoundingBox()
    • setTouchingScaffolding

      public void setTouchingScaffolding(boolean touchingScaffolding)
      Whether the player is inside scaffolding
    • setOnScaffolding

      public void setOnScaffolding(boolean onScaffolding)
      Whether the player is on top of scaffolding