Class CollisionManager

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

public class CollisionManager extends Object
  • Field Details

    • SOLID_COLLISION

      public static final BlockCollision SOLID_COLLISION
    • FLUID_COLLISION

      public static final BlockCollision FLUID_COLLISION
    • 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:
  • Constructor Details

    • CollisionManager

      public CollisionManager(GeyserSession session)
  • Method Details

    • updatePlayerBoundingBox

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

      public void updatePlayerBoundingBox(org.cloudburstmc.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
    • getActiveBoundingBox

      public BoundingBox getActiveBoundingBox()
      Gets the bounding box to use for player movement.

      This will return either the bounding box of a ClientVehicle, or the player's own bounding box.

      Returns:
      the bounding box to use for movement calculations
    • adjustBedrockPosition

      public @Nullable CollisionResult adjustBedrockPosition(org.cloudburstmc.math.vector.Vector3f bedrockPosition, 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
      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 org.geysermc.erosion.util.BlockPositionIterator collidableBlocksIterator(BoundingBox box)
    • playerCollidableBlocksIterator

      public org.geysermc.erosion.util.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 org.cloudburstmc.math.vector.Vector3d correctPlayerMovement(org.cloudburstmc.math.vector.Vector3d movement, boolean checkWorld, boolean teleported)
    • correctMovement

      public org.cloudburstmc.math.vector.Vector3d correctMovement(org.cloudburstmc.math.vector.Vector3d movement, BoundingBox boundingBox, boolean onGround, double stepUp, boolean checkWorld, boolean walkOnLava)
    • getCollisionLavaWalking

      public BlockCollision getCollisionLavaWalking(int blockId, int blockY, BoundingBox boundingBox)
      Returns:
      the block collision appropriate for entities that can walk on lava (Strider)
    • isPlayerInWater

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

      public boolean isWaterInEyes()
    • 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