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:
Ursprung
62822e0a2d
Commit
376b7ea988
@ -290,20 +290,21 @@ public class CollisionManager {
|
|||||||
stretchedBoundingBox.extend(horizontalMovement);
|
stretchedBoundingBox.extend(horizontalMovement);
|
||||||
double maxStepUp = correctMovementForCollisions(Vector3d.from(0, stepUp, 0), stretchedBoundingBox, checkWorld, walkOnLava).getY();
|
double maxStepUp = correctMovementForCollisions(Vector3d.from(0, stepUp, 0), stretchedBoundingBox, checkWorld, walkOnLava).getY();
|
||||||
if (maxStepUp < stepUp) { // The player collided with a block above them
|
if (maxStepUp < stepUp) { // The player collided with a block above them
|
||||||
boundingBox.translate(0, maxStepUp, 0);
|
BoundingBox stepUpBoundingBox = boundingBox.clone();
|
||||||
Vector3d adjustedStepUpMovement = correctMovementForCollisions(horizontalMovement, boundingBox, checkWorld, walkOnLava);
|
stepUpBoundingBox.translate(0, maxStepUp, 0);
|
||||||
boundingBox.translate(0, -maxStepUp, 0);
|
|
||||||
|
|
||||||
|
Vector3d adjustedStepUpMovement = correctMovementForCollisions(horizontalMovement, stepUpBoundingBox, checkWorld, walkOnLava);
|
||||||
if (squaredHorizontalLength(adjustedStepUpMovement) > squaredHorizontalLength(stepUpMovement)) {
|
if (squaredHorizontalLength(adjustedStepUpMovement) > squaredHorizontalLength(stepUpMovement)) {
|
||||||
stepUpMovement = adjustedStepUpMovement.up(maxStepUp);
|
stepUpMovement = adjustedStepUpMovement.up(maxStepUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (squaredHorizontalLength(stepUpMovement) > squaredHorizontalLength(adjustedMovement)) {
|
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
|
// Apply the player's remaining vertical movement
|
||||||
double verticalMovement = correctMovementForCollisions(Vector3d.from(0, movement.getY() - stepUpMovement.getY(), 0), boundingBox, checkWorld, walkOnLava).getY();
|
double verticalMovement = correctMovementForCollisions(Vector3d.from(0, movement.getY() - stepUpMovement.getY(), 0), stepUpBoundingBox, checkWorld, walkOnLava).getY();
|
||||||
boundingBox.translate(-stepUpMovement.getX(), -stepUpMovement.getY(), -stepUpMovement.getZ());
|
|
||||||
|
|
||||||
stepUpMovement = stepUpMovement.up(verticalMovement);
|
stepUpMovement = stepUpMovement.up(verticalMovement);
|
||||||
adjustedMovement = stepUpMovement;
|
adjustedMovement = stepUpMovement;
|
||||||
@ -321,6 +322,11 @@ public class CollisionManager {
|
|||||||
double movementY = movement.getY();
|
double movementY = movement.getY();
|
||||||
double movementZ = movement.getZ();
|
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();
|
BoundingBox movementBoundingBox = boundingBox.clone();
|
||||||
movementBoundingBox.extend(movement);
|
movementBoundingBox.extend(movement);
|
||||||
BlockPositionIterator iter = collidableBlocksIterator(movementBoundingBox);
|
BlockPositionIterator iter = collidableBlocksIterator(movementBoundingBox);
|
||||||
@ -342,7 +348,10 @@ public class CollisionManager {
|
|||||||
boundingBox.translate(0, 0, movementZ);
|
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);
|
return Vector3d.from(movementX, movementY, movementZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren