ClientboundResourcePackPushPacket 0x09

ClientboundResourcePackPushPacket: Minecraft 26.3 packet (0x09 Configuration clientbound, 0x52 Play clientbound).

Minecraft 26.3ConfigurationClientboundnet.minecraft.network.protocol.common

Protocol slots (2)

IDdecStateDirectionRegistry
0x099CONFIGURATIONClientboundCommonPacketTypes.CLIENTBOUND_RESOURCE_PACK_PUSH: "resource_pack_push"
0x5282PLAYClientboundCommonPacketTypes.CLIENTBOUND_RESOURCE_PACK_PUSH: "resource_pack_push"

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

FieldType
idUUID
urlString
hashString
requiredboolean
promptOptional<Component>

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, ClientboundResourcePackPushPacket> STREAM_CODEC = StreamCodec.composite( UUIDUtil.STREAM_CODEC, ClientboundResourcePackPushPacket::id, ByteBufCodecs.STRING_UTF8, Clie

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

Handling

Resolved on the ClientCommonPacketListener packet-listener interface by void handleResourcePackPush(ClientboundResourcePackPushPacket clientboundresourcepackpushpacket). The implementation in the game is ClientCommonPacketListenerImpl.

Full Source

ClientboundResourcePackPushPacket.java46 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.common;
2
3
import io.netty.buffer.ByteBuf;
4
import java.util.Optional;
5
import java.util.UUID;
6
import net.minecraft.core.UUIDUtil;
7
import net.minecraft.network.chat.Component;
8
import net.minecraft.network.chat.ComponentSerialization;
9
import net.minecraft.network.codec.ByteBufCodecs;
10
import net.minecraft.network.codec.StreamCodec;
11
import net.minecraft.network.protocol.Packet;
12
import net.minecraft.network.protocol.PacketType;
13
14
public record ClientboundResourcePackPushPacket(UUID id, String url, String hash, boolean required, Optional<Component> prompt)
15
	implements Packet<ClientCommonPacketListener> {
16
	public static final int MAX_HASH_LENGTH = 40;
17
	public static final StreamCodec<ByteBuf, ClientboundResourcePackPushPacket> STREAM_CODEC = StreamCodec.composite(
18
		UUIDUtil.STREAM_CODEC,
19
		ClientboundResourcePackPushPacket::id,
20
		ByteBufCodecs.STRING_UTF8,
21
		ClientboundResourcePackPushPacket::url,
22
		ByteBufCodecs.stringUtf8(40),
23
		ClientboundResourcePackPushPacket::hash,
24
		ByteBufCodecs.BOOL,
25
		ClientboundResourcePackPushPacket::required,
26
		ComponentSerialization.TRUSTED_CONTEXT_FREE_STREAM_CODEC.apply(ByteBufCodecs::optional),
27
		ClientboundResourcePackPushPacket::prompt,
28
		ClientboundResourcePackPushPacket::new
29
	);
30
31
	public ClientboundResourcePackPushPacket {
32
		if (hash.length() > 40) {
33
			throw new IllegalArgumentException("Hash is too long (max 40, was " + hash.length() + ")");
34
		}
35
	}
36
37
	@Override
38
	public PacketType<ClientboundResourcePackPushPacket> type() {
39
		return CommonPacketTypes.CLIENTBOUND_RESOURCE_PACK_PUSH;
40
	}
41
42
	public void handle(final ClientCommonPacketListener listener) {
43
		listener.handleResourcePackPush(this);
44
	}
45
}
46