ClientboundPlayerRotationPacket 0x4A

ClientboundPlayerRotationPacket: Minecraft 26.3 packet (0x4A Play clientbound). Wire name 'player_rotation', fields: yRot, relativeY, xRot, relativeX

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x4A74PLAYClientboundGamePacketTypes.CLIENTBOUND_PLAYER_ROTATION: "player_rotation"

Packet ids are positional: the id is the index of the addPacket call in the protocol builder (see ProtocolInfoBuilder.listPackets). Ids change between game versions.

Wire fields (4)

FieldType
yRotfloat
relativeYboolean
xRotfloat
relativeXboolean

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ClientboundPlayerRotationPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.FLOAT, ClientboundPlayerRotationPacket::yRot, ByteBufCodecs.BOOL, Clientb

Modern packets serialize through StreamCodecs instead of read/write methods.

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleRotatePlayer(ClientboundPlayerRotationPacket clientboundplayerrotationpacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundPlayerRotationPacket.java31 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.FriendlyByteBuf;
4
import net.minecraft.network.codec.ByteBufCodecs;
5
import net.minecraft.network.codec.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
9
public record ClientboundPlayerRotationPacket(float yRot, boolean relativeY, float xRot, boolean relativeX) implements Packet<ClientGamePacketListener> {
10
	public static final StreamCodec<FriendlyByteBuf, ClientboundPlayerRotationPacket> STREAM_CODEC = StreamCodec.composite(
11
		ByteBufCodecs.FLOAT,
12
		ClientboundPlayerRotationPacket::yRot,
13
		ByteBufCodecs.BOOL,
14
		ClientboundPlayerRotationPacket::relativeY,
15
		ByteBufCodecs.FLOAT,
16
		ClientboundPlayerRotationPacket::xRot,
17
		ByteBufCodecs.BOOL,
18
		ClientboundPlayerRotationPacket::relativeX,
19
		ClientboundPlayerRotationPacket::new
20
	);
21
22
	@Override
23
	public PacketType<ClientboundPlayerRotationPacket> type() {
24
		return GamePacketTypes.CLIENTBOUND_PLAYER_ROTATION;
25
	}
26
27
	public void handle(final ClientGamePacketListener listener) {
28
		listener.handleRotatePlayer(this);
29
	}
30
}
31