Class CollisionManager
java.lang.Object
org.geysermc.geyser.level.physics.CollisionManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleAdditional space where blocks are checked, which is helpful for fixing NoCheatPlus's Passable check.static final BlockCollisionstatic final BlockCollision -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable CollisionResultadjustBedrockPosition(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.org.geysermc.erosion.util.BlockPositionIteratororg.cloudburstmc.math.vector.Vector3dcorrectMovement(org.cloudburstmc.math.vector.Vector3d movement, BoundingBox boundingBox, boolean onGround, double stepUp, boolean checkWorld, boolean walkOnLava) org.cloudburstmc.math.vector.Vector3dcorrectPlayerMovement(org.cloudburstmc.math.vector.Vector3d movement, boolean checkWorld, boolean teleported) booleanReturns false if the movement is invalid, and in this case it shouldn't be sent to the server and should be cancelled SeeBlockCollision.correctPosition(GeyserSession, int, int, int, BoundingBox)for more infoGets the bounding box to use for player movement.getCollisionLavaWalking(int blockId, int blockY, BoundingBox boundingBox) booleanbooleanorg.geysermc.erosion.util.BlockPositionIteratorvoidvoidsetOnScaffolding(boolean onScaffolding) Whether the player is on top of scaffoldingvoidsetTouchingScaffolding(boolean touchingScaffolding) Whether the player is inside scaffoldingvoidUpdates the height of the stored bounding boxvoidupdatePlayerBoundingBox(org.cloudburstmc.math.vector.Vector3d position) Updates the stored bounding boxvoidupdatePlayerBoundingBox(org.cloudburstmc.math.vector.Vector3f position) Updates the stored bounding boxvoidupdateScaffoldingFlags(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
-
Field Details
-
SOLID_COLLISION
-
FLUID_COLLISION
-
COLLISION_TOLERANCE
public static final double COLLISION_TOLERANCEAdditional 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
-
-
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
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 clientteleported- 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
-
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 SeeBlockCollision.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
- 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
-
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
-