ClientboundServerDataPacket 0x58

ClientboundServerDataPacket: Minecraft 26.3 packet (0x58 Play clientbound). Wire name 'server_data', fields: motd, iconBytes, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x5888PLAYClientboundGamePacketTypes.CLIENTBOUND_SERVER_DATA: "server_data"

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
motdComponent
iconBytesOptional<byte[]>

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, ClientboundServerDataPacket> STREAM_CODEC = StreamCodec.composite( ComponentSerialization.TRUSTED_CONTEXT_FREE_STREAM_CODEC, ClientboundServerDataPacket::motd, ByteBu

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleServerData(ClientboundServerDataPacket clientboundserverdatapacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundServerDataPacket.java30 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import io.netty.buffer.ByteBuf;
4
import java.util.Optional;
5
import net.minecraft.network.chat.Component;
6
import net.minecraft.network.chat.ComponentSerialization;
7
import net.minecraft.network.codec.ByteBufCodecs;
8
import net.minecraft.network.codec.StreamCodec;
9
import net.minecraft.network.protocol.Packet;
10
import net.minecraft.network.protocol.PacketType;
11
12
public record ClientboundServerDataPacket(Component motd, Optional<byte[]> iconBytes) implements Packet<ClientGamePacketListener> {
13
	public static final StreamCodec<ByteBuf, ClientboundServerDataPacket> STREAM_CODEC = StreamCodec.composite(
14
		ComponentSerialization.TRUSTED_CONTEXT_FREE_STREAM_CODEC,
15
		ClientboundServerDataPacket::motd,
16
		ByteBufCodecs.BYTE_ARRAY.apply(ByteBufCodecs::optional),
17
		ClientboundServerDataPacket::iconBytes,
18
		ClientboundServerDataPacket::new
19
	);
20
21
	@Override
22
	public PacketType<ClientboundServerDataPacket> type() {
23
		return GamePacketTypes.CLIENTBOUND_SERVER_DATA;
24
	}
25
26
	public void handle(final ClientGamePacketListener listener) {
27
		listener.handleServerData(this);
28
	}
29
}
30