ServerboundBlockEntityTagQueryPacket 0x02

ServerboundBlockEntityTagQueryPacket: Minecraft 26.3 packet (0x02 Play serverbound). Wire name 'block_entity_tag_query', fields: transactionId, pos

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x022PLAYServerboundGamePacketTypes.SERVERBOUND_BLOCK_ENTITY_TAG_QUERY: "block_entity_tag_query"

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
transactionIdint
posBlockPos

Stream codec

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

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleBlockEntityTagQuery(ServerboundBlockEntityTagQueryPacket serverboundblockentitytagquerypacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundBlockEntityTagQueryPacket.java48 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
9
public class ServerboundBlockEntityTagQueryPacket implements Packet<ServerGamePacketListener> {
10
	public static final StreamCodec<FriendlyByteBuf, ServerboundBlockEntityTagQueryPacket> STREAM_CODEC = Packet.codec(
11
		ServerboundBlockEntityTagQueryPacket::write, ServerboundBlockEntityTagQueryPacket::new
12
	);
13
	private final int transactionId;
14
	private final BlockPos pos;
15
16
	public ServerboundBlockEntityTagQueryPacket(final int transactionId, final BlockPos pos) {
17
		this.transactionId = transactionId;
18
		this.pos = pos;
19
	}
20
21
	private ServerboundBlockEntityTagQueryPacket(final FriendlyByteBuf input) {
22
		this.transactionId = input.readVarInt();
23
		this.pos = input.readBlockPos();
24
	}
25
26
	private void write(final FriendlyByteBuf output) {
27
		output.writeVarInt(this.transactionId);
28
		output.writeBlockPos(this.pos);
29
	}
30
31
	@Override
32
	public PacketType<ServerboundBlockEntityTagQueryPacket> type() {
33
		return GamePacketTypes.SERVERBOUND_BLOCK_ENTITY_TAG_QUERY;
34
	}
35
36
	public void handle(final ServerGamePacketListener listener) {
37
		listener.handleBlockEntityTagQuery(this);
38
	}
39
40
	public int getTransactionId() {
41
		return this.transactionId;
42
	}
43
44
	public BlockPos getPos() {
45
		return this.pos;
46
	}
47
}
48