ServerboundSetJigsawBlockPacket 0x3B

ServerboundSetJigsawBlockPacket: Minecraft 26.3 packet (0x3B Play serverbound). Wire name 'set_jigsaw_block', fields: blockPos, name, target, pool

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x3B59PLAYServerboundGamePacketTypes.SERVERBOUND_SET_JIGSAW_BLOCK: "set_jigsaw_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 (8)

FieldType
blockPosBlockPos
nameIdentifier
targetIdentifier
poolIdentifier
finalStateString
jointJigsawBlockEntity.JointType
selectionPriorityint
placementPriorityint

Stream codec

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

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket serverboundsetjigsawblockpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundSetJigsawBlockPacket.java107 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.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
import net.minecraft.resources.Identifier;
9
import net.minecraft.world.level.block.entity.JigsawBlockEntity;
10
11
public class ServerboundSetJigsawBlockPacket implements Packet<ServerGamePacketListener> {
12
	public static final StreamCodec<FriendlyByteBuf, ServerboundSetJigsawBlockPacket> STREAM_CODEC = Packet.codec(
13
		ServerboundSetJigsawBlockPacket::write, ServerboundSetJigsawBlockPacket::new
14
	);
15
	private final BlockPos pos;
16
	private final Identifier name;
17
	private final Identifier target;
18
	private final Identifier pool;
19
	private final String finalState;
20
	private final JigsawBlockEntity.JointType joint;
21
	private final int selectionPriority;
22
	private final int placementPriority;
23
24
	public ServerboundSetJigsawBlockPacket(
25
		final BlockPos blockPos,
26
		final Identifier name,
27
		final Identifier target,
28
		final Identifier pool,
29
		final String finalState,
30
		final JigsawBlockEntity.JointType joint,
31
		final int selectionPriority,
32
		final int placementPriority
33
	) {
34
		this.pos = blockPos;
35
		this.name = name;
36
		this.target = target;
37
		this.pool = pool;
38
		this.finalState = finalState;
39
		this.joint = joint;
40
		this.selectionPriority = selectionPriority;
41
		this.placementPriority = placementPriority;
42
	}
43
44
	private ServerboundSetJigsawBlockPacket(final FriendlyByteBuf input) {
45
		this.pos = input.readBlockPos();
46
		this.name = input.readIdentifier();
47
		this.target = input.readIdentifier();
48
		this.pool = input.readIdentifier();
49
		this.finalState = input.readUtf();
50
		this.joint = JigsawBlockEntity.JointType.CODEC.byName(input.readUtf(), JigsawBlockEntity.JointType.ALIGNED);
51
		this.selectionPriority = input.readVarInt();
52
		this.placementPriority = input.readVarInt();
53
	}
54
55
	private void write(final FriendlyByteBuf output) {
56
		output.writeBlockPos(this.pos);
57
		output.writeIdentifier(this.name);
58
		output.writeIdentifier(this.target);
59
		output.writeIdentifier(this.pool);
60
		output.writeUtf(this.finalState);
61
		output.writeUtf(this.joint.getSerializedName());
62
		output.writeVarInt(this.selectionPriority);
63
		output.writeVarInt(this.placementPriority);
64
	}
65
66
	@Override
67
	public PacketType<ServerboundSetJigsawBlockPacket> type() {
68
		return GamePacketTypes.SERVERBOUND_SET_JIGSAW_BLOCK;
69
	}
70
71
	public void handle(final ServerGamePacketListener listener) {
72
		listener.handleSetJigsawBlock(this);
73
	}
74
75
	public BlockPos getPos() {
76
		return this.pos;
77
	}
78
79
	public Identifier getName() {
80
		return this.name;
81
	}
82
83
	public Identifier getTarget() {
84
		return this.target;
85
	}
86
87
	public Identifier getPool() {
88
		return this.pool;
89
	}
90
91
	public String getFinalState() {
92
		return this.finalState;
93
	}
94
95
	public JigsawBlockEntity.JointType getJoint() {
96
		return this.joint;
97
	}
98
99
	public int getSelectionPriority() {
100
		return this.selectionPriority;
101
	}
102
103
	public int getPlacementPriority() {
104
		return this.placementPriority;
105
	}
106
}
107