ServerboundSetBeaconPacket 0x35

ServerboundSetBeaconPacket: Minecraft 26.3 packet (0x35 Play serverbound). Wire name 'set_beacon', fields: primary, secondary, handled

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x3553PLAYServerboundGamePacketTypes.SERVERBOUND_SET_BEACON: "set_beacon"

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
primaryOptional<Holder<MobEffect>>
secondaryOptional<Holder<MobEffect>>

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ServerboundSetBeaconPacket> STREAM_CODEC = StreamCodec.composite( MobEffect.STREAM_CODEC.apply(ByteBufCodecs::optional), ServerboundSetBeaconPacket::p

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleSetBeaconPacket(ServerboundSetBeaconPacket serverboundsetbeaconpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundSetBeaconPacket.java30 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import java.util.Optional;
4
import net.minecraft.core.Holder;
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.world.effect.MobEffect;
11
12
public record ServerboundSetBeaconPacket(Optional<Holder<MobEffect>> primary, Optional<Holder<MobEffect>> secondary) implements Packet<ServerGamePacketListener> {
13
	public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundSetBeaconPacket> STREAM_CODEC = StreamCodec.composite(
14
		MobEffect.STREAM_CODEC.apply(ByteBufCodecs::optional),
15
		ServerboundSetBeaconPacket::primary,
16
		MobEffect.STREAM_CODEC.apply(ByteBufCodecs::optional),
17
		ServerboundSetBeaconPacket::secondary,
18
		ServerboundSetBeaconPacket::new
19
	);
20
21
	@Override
22
	public PacketType<ServerboundSetBeaconPacket> type() {
23
		return GamePacketTypes.SERVERBOUND_SET_BEACON;
24
	}
25
26
	public void handle(final ServerGamePacketListener listener) {
27
		listener.handleSetBeaconPacket(this);
28
	}
29
}
30