ServerboundSetTestBlockPacket 0x3D

ServerboundSetTestBlockPacket: Minecraft 26.3 packet (0x3D Play serverbound). Wire name 'set_test_block', fields: position, mode, message, handled

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x3D61PLAYServerboundGamePacketTypes.SERVERBOUND_SET_TEST_BLOCK: "set_test_block"

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

FieldType
positionBlockPos
modeTestBlockMode
messageString

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundSetTestBlockPacket> STREAM_CODEC = StreamCodec.composite( BlockPos.STREAM_CODEC, ServerboundSetTestBlockPacket::position, TestBlockMode.STREAM_CODE

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleSetTestBlock(ServerboundSetTestBlockPacket serverboundsettestblockpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundSetTestBlockPacket.java31 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.network.FriendlyByteBuf;
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
import net.minecraft.world.level.block.state.properties.TestBlockMode;
10
11
public record ServerboundSetTestBlockPacket(BlockPos position, TestBlockMode mode, String message) implements Packet<ServerGamePacketListener> {
12
	public static final StreamCodec<FriendlyByteBuf, ServerboundSetTestBlockPacket> STREAM_CODEC = StreamCodec.composite(
13
		BlockPos.STREAM_CODEC,
14
		ServerboundSetTestBlockPacket::position,
15
		TestBlockMode.STREAM_CODEC,
16
		ServerboundSetTestBlockPacket::mode,
17
		ByteBufCodecs.STRING_UTF8,
18
		ServerboundSetTestBlockPacket::message,
19
		ServerboundSetTestBlockPacket::new
20
	);
21
22
	@Override
23
	public PacketType<ServerboundSetTestBlockPacket> type() {
24
		return GamePacketTypes.SERVERBOUND_SET_TEST_BLOCK;
25
	}
26
27
	public void handle(final ServerGamePacketListener listener) {
28
		listener.handleSetTestBlock(this);
29
	}
30
}
31