ClientboundAwardStatsPacket 0x03

ClientboundAwardStatsPacket: Minecraft 26.3 packet (0x03 Play clientbound). Wire name 'award_stats', fields: stats, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x033PLAYClientboundGamePacketTypes.CLIENTBOUND_AWARD_STATS: "award_stats"

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
statsObject2IntMap<Stat<?>>

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, Object2IntMap<Stat<?>>> STAT_VALUES_STREAM_CODEC = ByteBufCodecs.map( Object2IntOpenHashMap::new, Stat.STREAM_CODEC, ByteBufCodecs.VAR_INT );

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleAwardStats(ClientboundAwardStatsPacket clientboundawardstatspacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundAwardStatsPacket.java29 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import it.unimi.dsi.fastutil.objects.Object2IntMap;
4
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
5
import net.minecraft.network.RegistryFriendlyByteBuf;
6
import net.minecraft.network.codec.ByteBufCodecs;
7
import net.minecraft.network.codec.StreamCodec;
8
import net.minecraft.network.protocol.Packet;
9
import net.minecraft.network.protocol.PacketType;
10
import net.minecraft.stats.Stat;
11
12
public record ClientboundAwardStatsPacket(Object2IntMap<Stat<?>> stats) implements Packet<ClientGamePacketListener> {
13
	private static final StreamCodec<RegistryFriendlyByteBuf, Object2IntMap<Stat<?>>> STAT_VALUES_STREAM_CODEC = ByteBufCodecs.map(
14
		Object2IntOpenHashMap::new, Stat.STREAM_CODEC, ByteBufCodecs.VAR_INT
15
	);
16
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundAwardStatsPacket> STREAM_CODEC = STAT_VALUES_STREAM_CODEC.map(
17
		ClientboundAwardStatsPacket::new, ClientboundAwardStatsPacket::stats
18
	);
19
20
	@Override
21
	public PacketType<ClientboundAwardStatsPacket> type() {
22
		return GamePacketTypes.CLIENTBOUND_AWARD_STATS;
23
	}
24
25
	public void handle(final ClientGamePacketListener listener) {
26
		listener.handleAwardStats(this);
27
	}
28
}
29