The Bug
ServerboundMovePlayerPacket's xRot can have invalid(90 over or -90 under) value.
An xRot value greater than 90 or less than -90 is an xRot value that players cannot have.
Can check it enter the command
/tp @s ~ ~ ~ ~ -180
or look at the sky and enter the command
/tp @s ~ ~ ~ ~ ~-5
In special cases, the client can also cause packet spam. (ex. send -95 to the server and immediately send -90)
Code analysis
net.minecraft.client.multiplayer.ClientPacketListener
@Override
public void handleMovePlayer(ClientboundPlayerPositionPacket packet) {
// ...
localPlayer.setPos(d1, d3, d5);
localPlayer.setDeltaMovement(d0, d2, d4);
float f = packet.getYRot();
float f1 = packet.getXRot();
if (packet.getRelativeArguments().contains(ClientboundPlayerPositionPacket.RelativeArgument.X_ROT)) {
// If the player's current xRot is -90 and the "float f1" is -1, the player's xRot will be -91.
// and the client sends -91 to the server.
localPlayer.setXRot(localPlayer.getXRot() + f1);
localPlayer.xRotO += f1;
// fix example (this would not be a good way)
// localPlayer.setXRot(Mth.clamp(localPlayer.getXRot() + f1, -90.0F, 90.0F));
// localPlayer.xRotO = Mth.clamp(localPlayer.xRotO + f1, -90.0F, 90.0F);
} else {
// It's the same.
localPlayer.setXRot(f1);
localPlayer.xRotO = f1;
}
// ...
this.connection.send(new ServerboundAcceptTeleportationPacket(packet.getId()));
this.connection.send(new ServerboundMovePlayerPacket.PosRot(localPlayer.getX(), localPlayer.getY(), localPlayer.getZ(), localPlayer.getYRot(), localPlayer.getXRot(), false));
}
Linked issues
is duplicated by 2
relates to 3
Attachments
Comments 8
Sends xRot values that the player cannot have to the server
client can make impossible moves.
There is no problem with 1.19.2 or less. (It's calibrated by the client)
@unknown please could you state the precise gameplay impact that Mojang can diagnose and potentially triage this issue. In other words, how does this problem affect gameplay? You've mentioned that it occurs in vanilla; all we need now is an explanation of how this affects gameplay. Thanks 🙂
First, I was making a recoil(gun, helicopter and etc...) system. (using Relative Teleport)
However, this bug prevents me from performing the intended action.
-------
As you can see in the video, the player can take actions that are impossible.
[media]-------
From the viewpoint of the third-party server operator(or Developer)
Sends xRot(Pitch) values to the server that the player cannot have.
Clients spam packets to the server to correct invalid pitch values.
From the viewpoint of the player
The game player can see the impossible action.
and more?.. (i don't know)
From the viewpoint of the content creator
When using the relative teleport, the player can see unintended actions.
There are too many omitted expressions because I am not good at English. I'm sorry.
Relates to MC-45104.
I I also suggest adding a few more keywordsto make this easier to find: pitch, chat, teleport (tp is listed, but teleport is better for searching).
Does this have an effect on gameplay?