Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Fix getting stuck in wall bug
Due to java doubles being somewhat more "precise" and bedrock positions being sent in floats instead, this caused bedrock players to get stuck in blocks when jumping or running near them in a certain way, thus causing the server to try and correct their position, potentially flagging anticheats and causing the server to print a "moved wrongly" message in console. See: https://stackoverflow.com/questions/322749/retain-precision-with-double-in-java
Dieser Commit ist enthalten in:
Ursprung
1af4d71bd1
Commit
f0e01ab1c9
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.connector.network.translators.bedrock;
|
package org.geysermc.connector.network.translators.bedrock;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||||
|
import com.nukkitx.math.GenericMath;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||||
@ -63,8 +64,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
|||||||
|
|
||||||
double javaY = Math.ceil((packet.getPosition().getY() - EntityType.PLAYER.getOffset()) * 2) / 2;
|
double javaY = Math.ceil((packet.getPosition().getY() - EntityType.PLAYER.getOffset()) * 2) / 2;
|
||||||
ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket(
|
ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket(
|
||||||
packet.isOnGround(), packet.getPosition().getX(), javaY,
|
packet.isOnGround(), GenericMath.round(packet.getPosition().getX(), 4), javaY, GenericMath.round(packet.getPosition().getZ(), 4), packet.getRotation().getY(), packet.getRotation().getX()
|
||||||
packet.getPosition().getZ(), packet.getRotation().getY(), packet.getRotation().getX()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// head yaw, pitch, head yaw
|
// head yaw, pitch, head yaw
|
||||||
|
@ -87,10 +87,9 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
|||||||
if (!packet.getRelative().isEmpty()) {
|
if (!packet.getRelative().isEmpty()) {
|
||||||
entity.moveRelative(session, packet.getX(), packet.getY() + EntityType.PLAYER.getOffset() + 0.1f, packet.getZ(), packet.getYaw(), packet.getPitch(), true);
|
entity.moveRelative(session, packet.getX(), packet.getY() + EntityType.PLAYER.getOffset() + 0.1f, packet.getZ(), packet.getYaw(), packet.getPitch(), true);
|
||||||
} else {
|
} else {
|
||||||
float xDis = Math.abs(entity.getPosition().getX() - (float) packet.getX());
|
double xDis = Math.abs(entity.getPosition().getX() - packet.getX());
|
||||||
float yDis = entity.getPosition().getY() - (float) packet.getY();
|
double yDis = entity.getPosition().getY() - packet.getY();
|
||||||
float zDis = Math.abs(entity.getPosition().getZ() - (float) packet.getZ());
|
double zDis = Math.abs(entity.getPosition().getZ() - packet.getZ());
|
||||||
|
|
||||||
if (xDis > 1.5 || (yDis < 1.45 || yDis > (session.isJumping() ? 4.3 : (session.isSprinting() ? 2.5 : 1.9))) || zDis > 1.5) {
|
if (xDis > 1.5 || (yDis < 1.45 || yDis > (session.isJumping() ? 4.3 : (session.isSprinting() ? 2.5 : 1.9))) || zDis > 1.5) {
|
||||||
entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), true);
|
entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), true);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren