3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Fix bug causing BoundingBox position to change in CollisionManager

Dieser Commit ist enthalten in:
AJ Ferguson 2024-05-21 21:51:26 -04:00
Ursprung 62822e0a2d
Commit 376b7ea988

Datei anzeigen

@ -290,20 +290,21 @@ public class CollisionManager {
stretchedBoundingBox.extend(horizontalMovement);
double maxStepUp = correctMovementForCollisions(Vector3d.from(0, stepUp, 0), stretchedBoundingBox, checkWorld, walkOnLava).getY();
if (maxStepUp < stepUp) { // The player collided with a block above them
boundingBox.translate(0, maxStepUp, 0);
Vector3d adjustedStepUpMovement = correctMovementForCollisions(horizontalMovement, boundingBox, checkWorld, walkOnLava);
boundingBox.translate(0, -maxStepUp, 0);
BoundingBox stepUpBoundingBox = boundingBox.clone();
stepUpBoundingBox.translate(0, maxStepUp, 0);
Vector3d adjustedStepUpMovement = correctMovementForCollisions(horizontalMovement, stepUpBoundingBox, checkWorld, walkOnLava);
if (squaredHorizontalLength(adjustedStepUpMovement) > squaredHorizontalLength(stepUpMovement)) {
stepUpMovement = adjustedStepUpMovement.up(maxStepUp);
}
}
if (squaredHorizontalLength(stepUpMovement) > squaredHorizontalLength(adjustedMovement)) {
boundingBox.translate(stepUpMovement.getX(), stepUpMovement.getY(), stepUpMovement.getZ());
BoundingBox stepUpBoundingBox = boundingBox.clone();
stepUpBoundingBox.translate(stepUpMovement.getX(), stepUpMovement.getY(), stepUpMovement.getZ());
// Apply the player's remaining vertical movement
double verticalMovement = correctMovementForCollisions(Vector3d.from(0, movement.getY() - stepUpMovement.getY(), 0), boundingBox, checkWorld, walkOnLava).getY();
boundingBox.translate(-stepUpMovement.getX(), -stepUpMovement.getY(), -stepUpMovement.getZ());
double verticalMovement = correctMovementForCollisions(Vector3d.from(0, movement.getY() - stepUpMovement.getY(), 0), stepUpBoundingBox, checkWorld, walkOnLava).getY();
stepUpMovement = stepUpMovement.up(verticalMovement);
adjustedMovement = stepUpMovement;
@ -321,6 +322,11 @@ public class CollisionManager {
double movementY = movement.getY();
double movementZ = movement.getZ();
// Position might change slightly due to floating point error
double originalX = boundingBox.getMiddleX();
double originalY = boundingBox.getMiddleY();
double originalZ = boundingBox.getMiddleZ();
BoundingBox movementBoundingBox = boundingBox.clone();
movementBoundingBox.extend(movement);
BlockPositionIterator iter = collidableBlocksIterator(movementBoundingBox);
@ -342,7 +348,10 @@ public class CollisionManager {
boundingBox.translate(0, 0, movementZ);
}
boundingBox.translate(-movementX, -movementY, -movementZ);
boundingBox.setMiddleX(originalX);
boundingBox.setMiddleY(originalY);
boundingBox.setMiddleZ(originalZ);
return Vector3d.from(movementX, movementY, movementZ);
}