ServerboundSpectatorActionPacket 0x3F

ServerboundSpectatorActionPacket: Minecraft 26.3 packet (0x3F Play serverbound). Wire name 'spectator_action', fields: spectateEntityId, handled

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x3F63PLAYServerboundGamePacketTypes.SERVERBOUND_SPECTATOR_ACTION: "spectator_action"

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
spectateEntityIdOptionalInt

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, ServerboundSpectatorActionPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.OPTIONAL_VAR_INT, ServerboundSpectatorActionPacket::spectateEntityId, Serverboun

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleSpectatorAction(ServerboundSpectatorActionPacket serverboundspectatoractionpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundSpectatorActionPacket.java24 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import io.netty.buffer.ByteBuf;
4
import java.util.OptionalInt;
5
import net.minecraft.network.codec.ByteBufCodecs;
6
import net.minecraft.network.codec.StreamCodec;
7
import net.minecraft.network.protocol.Packet;
8
import net.minecraft.network.protocol.PacketType;
9
10
public record ServerboundSpectatorActionPacket(OptionalInt spectateEntityId) implements Packet<ServerGamePacketListener> {
11
	public static final StreamCodec<ByteBuf, ServerboundSpectatorActionPacket> STREAM_CODEC = StreamCodec.composite(
12
		ByteBufCodecs.OPTIONAL_VAR_INT, ServerboundSpectatorActionPacket::spectateEntityId, ServerboundSpectatorActionPacket::new
13
	);
14
15
	@Override
16
	public PacketType<ServerboundSpectatorActionPacket> type() {
17
		return GamePacketTypes.SERVERBOUND_SPECTATOR_ACTION;
18
	}
19
20
	public void handle(final ServerGamePacketListener listener) {
21
		listener.handleSpectatorAction(this);
22
	}
23
}
24