diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java index b482e9ea6..195f5dcea 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java @@ -94,6 +94,11 @@ final class BedrockMovePlayer { boolean positionChangedAndShouldUpdate = !hasVehicle && (session.getInputCache().shouldSendPositionReminder() || actualPositionChanged); 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. 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())); @@ -134,10 +139,14 @@ final class BedrockMovePlayer { continue; } + if (other == entity) { + continue; + } + 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. - 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)) { possibleOnGround = true; @@ -176,11 +185,11 @@ final class BedrockMovePlayer { } } else if (positionChangedAndShouldUpdate) { 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)); - if (result != null) { // A null return value cancels the packet - Vector3d position = result.correctedMovement(); + CollisionResult result = session.getCollisionManager().adjustBedrockPosition(packet.getPosition(), isOnGround, packet.getInputData().contains(PlayerAuthInputData.HANDLE_TELEPORT)); + if (result != null) { // A null return value cancels the packet + Vector3d position = result.correctedMovement(); + if (!session.getWorldBorder().isPassingIntoBorderBoundaries(position.toFloat(), true)) { Packet movePacket; if (rotationChanged) { // Send rotation updates as well @@ -206,6 +215,8 @@ final class BedrockMovePlayer { session.getInputCache().markPositionPacketSent(); session.getSkullCache().updateVisibleSkulls(); + } else { + session.getCollisionManager().recalculatePosition(); } } } else { @@ -247,4 +258,3 @@ final class BedrockMovePlayer { return true; } } -