ServerboundResourcePackPacket 0x06

ServerboundResourcePackPacket: Minecraft 26.3 packet (0x06 Configuration serverbound, 0x32 Play serverbound).

Minecraft 26.3ConfigurationServerboundnet.minecraft.network.protocol.common

Protocol slots (2)

IDdecStateDirectionRegistry
0x066CONFIGURATIONServerboundCommonPacketTypes.SERVERBOUND_RESOURCE_PACK: "resource_pack"
0x3250PLAYServerboundCommonPacketTypes.SERVERBOUND_RESOURCE_PACK: "resource_pack"

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
idUUID
actionServerboundResourcePackPacket.Action

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundResourcePackPacket> STREAM_CODEC = Packet.codec( ServerboundResourcePackPacket::write, ServerboundResourcePackPacket::new );

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

Handling

Resolved on the ServerCommonPacketListener packet-listener interface by void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket). The implementation in the game is ServerCommonPacketListenerImpl.

Full Source

ServerboundResourcePackPacket.java47 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.common;
2
3
import java.util.UUID;
4
import net.minecraft.network.FriendlyByteBuf;
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 ServerboundResourcePackPacket(UUID id, ServerboundResourcePackPacket.Action action) implements Packet<ServerCommonPacketListener> {
10
	public static final StreamCodec<FriendlyByteBuf, ServerboundResourcePackPacket> STREAM_CODEC = Packet.codec(
11
		ServerboundResourcePackPacket::write, ServerboundResourcePackPacket::new
12
	);
13
14
	private ServerboundResourcePackPacket(final FriendlyByteBuf input) {
15
		this(input.readUUID(), input.readEnum(ServerboundResourcePackPacket.Action.class));
16
	}
17
18
	private void write(final FriendlyByteBuf output) {
19
		output.writeUUID(this.id);
20
		output.writeEnum(this.action);
21
	}
22
23
	@Override
24
	public PacketType<ServerboundResourcePackPacket> type() {
25
		return CommonPacketTypes.SERVERBOUND_RESOURCE_PACK;
26
	}
27
28
	public void handle(final ServerCommonPacketListener listener) {
29
		listener.handleResourcePackResponse(this);
30
	}
31
32
	public enum Action {
33
		SUCCESSFULLY_LOADED,
34
		DECLINED,
35
		FAILED_DOWNLOAD,
36
		ACCEPTED,
37
		DOWNLOADED,
38
		INVALID_URL,
39
		FAILED_RELOAD,
40
		DISCARDED;
41
42
		public boolean isTerminal() {
43
			return this != ACCEPTED && this != DOWNLOADED;
44
		}
45
	}
46
}
47