mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix movement when far away from the center of the world (#419)
* Fix movement when far away from the center of the world * Add comment on why we parse a float as string Co-authored-by: Redned <redned235@gmail.com>
This commit is contained in:
parent
e82adf2cf9
commit
357b681841
1 changed files with 3 additions and 1 deletions
|
@ -67,8 +67,10 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||||
|
|
||||||
double javaY = packet.getPosition().getY() - EntityType.PLAYER.getOffset();
|
double javaY = packet.getPosition().getY() - EntityType.PLAYER.getOffset();
|
||||||
if (packet.isOnGround()) javaY = Math.ceil(javaY * 2) / 2;
|
if (packet.isOnGround()) javaY = Math.ceil(javaY * 2) / 2;
|
||||||
|
// We need to parse the float as a string since casting a float to a double causes us to
|
||||||
|
// lose precision and thus, causes players to get stuck when walking near walls
|
||||||
ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket(
|
ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket(
|
||||||
packet.isOnGround(), GenericMath.round(packet.getPosition().getX(), 4), javaY, GenericMath.round(packet.getPosition().getZ(), 4), packet.getRotation().getY(), packet.getRotation().getX()
|
packet.isOnGround(), Double.parseDouble(Float.toString(packet.getPosition().getX())), javaY, Double.parseDouble(Float.toString(packet.getPosition().getZ())), packet.getRotation().getY(), packet.getRotation().getX()
|
||||||
);
|
);
|
||||||
|
|
||||||
// head yaw, pitch, head yaw
|
// head yaw, pitch, head yaw
|
||||||
|
|
Loading…
Reference in a new issue