mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-21 15:59:32 +00:00
Fix chunks not loading when riding a vehicle, fix world border corrections not applying (#5410)
This commit is contained in:
@@ -76,7 +76,7 @@ final class BedrockMovePlayer {
|
||||
boolean hasVehicle = entity.getVehicle() != null;
|
||||
|
||||
// shouldSendPositionReminder also increments a tick counter, so make sure it's always called unless the player is on a vehicle.
|
||||
boolean positionChanged = !hasVehicle && (session.getInputCache().shouldSendPositionReminder() || actualPositionChanged);
|
||||
boolean positionChangedAndShouldUpdate = !hasVehicle && (session.getInputCache().shouldSendPositionReminder() || actualPositionChanged);
|
||||
boolean rotationChanged = hasVehicle || (entity.getYaw() != yaw || entity.getPitch() != pitch || entity.getHeadYaw() != headYaw);
|
||||
|
||||
if (session.getLookBackScheduledFuture() != null) {
|
||||
@@ -87,15 +87,23 @@ final class BedrockMovePlayer {
|
||||
}
|
||||
|
||||
// Client is telling us it wants to move down, but something is blocking it from doing so.
|
||||
boolean isOnGround = packet.getInputData().contains(PlayerAuthInputData.VERTICAL_COLLISION) && packet.getDelta().getY() < 0;
|
||||
boolean isOnGround;
|
||||
if (hasVehicle) {
|
||||
// VERTICAL_COLLISION is not accurate while in a vehicle (as of 1.21.62)
|
||||
isOnGround = Math.abs(packet.getDelta().getY()) < 0.1;
|
||||
} else {
|
||||
isOnGround = packet.getInputData().contains(PlayerAuthInputData.VERTICAL_COLLISION) && packet.getDelta().getY() < 0;
|
||||
}
|
||||
|
||||
// This takes into account no movement sent from the client, but the player is trying to move anyway.
|
||||
// (Press into a wall in a corner - you're trying to move but nothing actually happens)
|
||||
// This isn't sent when a player is riding a vehicle (as of 1.21.62)
|
||||
boolean horizontalCollision = packet.getInputData().contains(PlayerAuthInputData.HORIZONTAL_COLLISION);
|
||||
|
||||
// If only the pitch and yaw changed
|
||||
// This isn't needed, but it makes the packets closer to vanilla
|
||||
// It also means you can't "lag back" while only looking, in theory
|
||||
if (!positionChanged && rotationChanged) {
|
||||
if (!positionChangedAndShouldUpdate && rotationChanged) {
|
||||
ServerboundMovePlayerRotPacket playerRotationPacket = new ServerboundMovePlayerRotPacket(isOnGround, horizontalCollision, yaw, pitch);
|
||||
|
||||
entity.setYaw(yaw);
|
||||
@@ -103,8 +111,15 @@ final class BedrockMovePlayer {
|
||||
entity.setHeadYaw(headYaw);
|
||||
|
||||
session.sendDownstreamGamePacket(playerRotationPacket);
|
||||
} else if (positionChanged) {
|
||||
|
||||
// Player position MUST be updated on our end, otherwise e.g. chunk loading breaks
|
||||
if (hasVehicle) {
|
||||
entity.setPositionManual(packet.getPosition());
|
||||
session.getSkullCache().updateVisibleSkulls();
|
||||
}
|
||||
} 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();
|
||||
@@ -169,6 +184,7 @@ final class BedrockMovePlayer {
|
||||
session.getInputCache().markPositionPacketSent();
|
||||
session.getSkullCache().updateVisibleSkulls();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not a valid move
|
||||
session.getGeyser().getLogger().debug("Recalculating position...");
|
||||
|
||||
Reference in New Issue
Block a user