mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-19 14:59:27 +00:00
Fix: Correct void collisions, check rotation values and correct world border check (#5797)
* fix(bedrock-movement): correct void collisions, rotation packets and world border checks * fix(bedrock-movement): use position.toFloat() directly in world border check * fix(bedrock-movement): correct odd formatting
This commit is contained in:
@@ -94,6 +94,11 @@ final class BedrockMovePlayer {
|
|||||||
boolean positionChangedAndShouldUpdate = !hasVehicle && (session.getInputCache().shouldSendPositionReminder() || actualPositionChanged);
|
boolean positionChangedAndShouldUpdate = !hasVehicle && (session.getInputCache().shouldSendPositionReminder() || actualPositionChanged);
|
||||||
boolean rotationChanged = hasVehicle || (entity.getJavaYaw() != javaYaw || entity.getPitch() != pitch);
|
boolean rotationChanged = hasVehicle || (entity.getJavaYaw() != javaYaw || entity.getPitch() != pitch);
|
||||||
|
|
||||||
|
// Drop invalid rotation packets
|
||||||
|
if (isInvalidNumber(yaw) || isInvalidNumber(pitch) || isInvalidNumber(headYaw)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Simulate jumping since it happened this tick, not from the last tick end.
|
// Simulate jumping since it happened this tick, not from the last tick end.
|
||||||
if (entity.isOnGround() && packet.getInputData().contains(PlayerAuthInputData.START_JUMPING)) {
|
if (entity.isOnGround() && packet.getInputData().contains(PlayerAuthInputData.START_JUMPING)) {
|
||||||
entity.setLastTickEndVelocity(Vector3f.from(entity.getLastTickEndVelocity().getX(), Math.max(entity.getLastTickEndVelocity().getY(), entity.getJumpVelocity()), entity.getLastTickEndVelocity().getZ()));
|
entity.setLastTickEndVelocity(Vector3f.from(entity.getLastTickEndVelocity().getX(), Math.max(entity.getLastTickEndVelocity().getY(), entity.getJumpVelocity()), entity.getLastTickEndVelocity().getZ()));
|
||||||
@@ -134,10 +139,14 @@ final class BedrockMovePlayer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (other == entity) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final BoundingBox entityBoundingBox = new BoundingBox(0, 0, 0, other.getBoundingBoxWidth(), other.getBoundingBoxHeight(), other.getBoundingBoxWidth());
|
final BoundingBox entityBoundingBox = new BoundingBox(0, 0, 0, other.getBoundingBoxWidth(), other.getBoundingBoxHeight(), other.getBoundingBoxWidth());
|
||||||
|
|
||||||
// Also offset the position down for boat as their position is offset.
|
// Also offset the position down for boat as their position is offset.
|
||||||
entityBoundingBox.translate(other.getPosition().down(other instanceof BoatEntity ? entity.getDefinition().offset() : 0).toDouble());
|
entityBoundingBox.translate(other.getPosition().down(other instanceof BoatEntity ? other.getDefinition().offset() : 0).toDouble());
|
||||||
|
|
||||||
if (entityBoundingBox.checkIntersection(boundingBox)) {
|
if (entityBoundingBox.checkIntersection(boundingBox)) {
|
||||||
possibleOnGround = true;
|
possibleOnGround = true;
|
||||||
@@ -176,11 +185,11 @@ final class BedrockMovePlayer {
|
|||||||
}
|
}
|
||||||
} else if (positionChangedAndShouldUpdate) {
|
} else if (positionChangedAndShouldUpdate) {
|
||||||
if (isValidMove(session, entity.getPosition(), packet.getPosition())) {
|
if (isValidMove(session, entity.getPosition(), packet.getPosition())) {
|
||||||
if (!session.getWorldBorder().isPassingIntoBorderBoundaries(entity.getPosition(), true)) {
|
|
||||||
CollisionResult result = session.getCollisionManager().adjustBedrockPosition(packet.getPosition(), isOnGround, packet.getInputData().contains(PlayerAuthInputData.HANDLE_TELEPORT));
|
CollisionResult result = session.getCollisionManager().adjustBedrockPosition(packet.getPosition(), isOnGround, packet.getInputData().contains(PlayerAuthInputData.HANDLE_TELEPORT));
|
||||||
if (result != null) { // A null return value cancels the packet
|
if (result != null) { // A null return value cancels the packet
|
||||||
Vector3d position = result.correctedMovement();
|
Vector3d position = result.correctedMovement();
|
||||||
|
|
||||||
|
if (!session.getWorldBorder().isPassingIntoBorderBoundaries(position.toFloat(), true)) {
|
||||||
Packet movePacket;
|
Packet movePacket;
|
||||||
if (rotationChanged) {
|
if (rotationChanged) {
|
||||||
// Send rotation updates as well
|
// Send rotation updates as well
|
||||||
@@ -206,6 +215,8 @@ final class BedrockMovePlayer {
|
|||||||
|
|
||||||
session.getInputCache().markPositionPacketSent();
|
session.getInputCache().markPositionPacketSent();
|
||||||
session.getSkullCache().updateVisibleSkulls();
|
session.getSkullCache().updateVisibleSkulls();
|
||||||
|
} else {
|
||||||
|
session.getCollisionManager().recalculatePosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -247,4 +258,3 @@ final class BedrockMovePlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user