ServerboundContainerButtonClickPacket 0x11

ServerboundContainerButtonClickPacket: Minecraft 26.3 packet (0x11 Play serverbound). Wire name 'container_button_click', fields: containerId, buttonId

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x1117PLAYServerboundGamePacketTypes.SERVERBOUND_CONTAINER_BUTTON_CLICK: "container_button_click"

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

FieldType
containerIdint
buttonIdint

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundContainerButtonClickPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.CONTAINER_ID, ServerboundContainerButtonClickPacket::containerId, B

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleContainerButtonClick(ServerboundContainerButtonClickPacket serverboundcontainerbuttonclickpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundContainerButtonClickPacket.java27 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 ServerboundContainerButtonClickPacket(int containerId, int buttonId) implements Packet<ServerGamePacketListener> {
10
	public static final StreamCodec<FriendlyByteBuf, ServerboundContainerButtonClickPacket> STREAM_CODEC = StreamCodec.composite(
11
		ByteBufCodecs.CONTAINER_ID,
12
		ServerboundContainerButtonClickPacket::containerId,
13
		ByteBufCodecs.VAR_INT,
14
		ServerboundContainerButtonClickPacket::buttonId,
15
		ServerboundContainerButtonClickPacket::new
16
	);
17
18
	@Override
19
	public PacketType<ServerboundContainerButtonClickPacket> type() {
20
		return GamePacketTypes.SERVERBOUND_CONTAINER_BUTTON_CLICK;
21
	}
22
23
	public void handle(final ServerGamePacketListener listener) {
24
		listener.handleContainerButtonClick(this);
25
	}
26
}
27