ServerboundPlayerInputPacket 0x2B

ServerboundPlayerInputPacket: Minecraft 26.3 packet (0x2B Play serverbound). Wire name 'player_input', fields: input, handled

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x2B43PLAYServerboundGamePacketTypes.SERVERBOUND_PLAYER_INPUT: "player_input"

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 (1)

FieldType
inputInput

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundPlayerInputPacket> STREAM_CODEC = StreamCodec.composite( Input.STREAM_CODEC, ServerboundPlayerInputPacket::input, ServerboundPlayerInputPacket::new

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handlePlayerInput(ServerboundPlayerInputPacket serverboundplayerinputpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundPlayerInputPacket.java23 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.StreamCodec;
5
import net.minecraft.network.protocol.Packet;
6
import net.minecraft.network.protocol.PacketType;
7
import net.minecraft.world.entity.player.Input;
8
9
public record ServerboundPlayerInputPacket(Input input) implements Packet<ServerGamePacketListener> {
10
	public static final StreamCodec<FriendlyByteBuf, ServerboundPlayerInputPacket> STREAM_CODEC = StreamCodec.composite(
11
		Input.STREAM_CODEC, ServerboundPlayerInputPacket::input, ServerboundPlayerInputPacket::new
12
	);
13
14
	@Override
15
	public PacketType<ServerboundPlayerInputPacket> type() {
16
		return GamePacketTypes.SERVERBOUND_PLAYER_INPUT;
17
	}
18
19
	public void handle(final ServerGamePacketListener listener) {
20
		listener.handlePlayerInput(this);
21
	}
22
}
23