DebugQueryHandler .java

net.minecraft.client.DebugQueryHandler (class): members: queryBlockEntityTag, queryEntityTag, handleResponse, transactionId, connection, callback.

net.minecraft.clientclass48 linesclient1.6 KB

API Surface (3)

boolean handleResponse(final int transactionId, final @Nullable CompoundTag tag)
void queryEntityTag(final int entityId, final Consumer<CompoundTag> callback)
void queryBlockEntityTag(final BlockPos blockPos, final Consumer<CompoundTag> callback)

Fields & Constants (3)

connection
transactionId
callback

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

DebugQueryHandler.java48 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client;
2
3
import java.util.function.Consumer;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.multiplayer.ClientPacketListener;
7
import net.minecraft.core.BlockPos;
8
import net.minecraft.nbt.CompoundTag;
9
import net.minecraft.network.protocol.game.ServerboundBlockEntityTagQueryPacket;
10
import net.minecraft.network.protocol.game.ServerboundEntityTagQueryPacket;
11
import org.jspecify.annotations.Nullable;
12
13
@Environment(EnvType.CLIENT)
14
public class DebugQueryHandler {
15
	private final ClientPacketListener connection;
16
	private int transactionId = -1;
17
	private @Nullable Consumer<CompoundTag> callback;
18
19
	public DebugQueryHandler(final ClientPacketListener connection) {
20
		this.connection = connection;
21
	}
22
23
	public boolean handleResponse(final int transactionId, final @Nullable CompoundTag tag) {
24
		if (this.transactionId == transactionId && this.callback != null) {
25
			this.callback.accept(tag);
26
			this.callback = null;
27
			return true;
28
		} else {
29
			return false;
30
		}
31
	}
32
33
	private int startTransaction(final Consumer<CompoundTag> callback) {
34
		this.callback = callback;
35
		return ++this.transactionId;
36
	}
37
38
	public void queryEntityTag(final int entityId, final Consumer<CompoundTag> callback) {
39
		int transactionId = this.startTransaction(callback);
40
		this.connection.send(new ServerboundEntityTagQueryPacket(transactionId, entityId));
41
	}
42
43
	public void queryBlockEntityTag(final BlockPos blockPos, final Consumer<CompoundTag> callback) {
44
		int transactionId = this.startTransaction(callback);
45
		this.connection.send(new ServerboundBlockEntityTagQueryPacket(transactionId, blockPos));
46
	}
47
}
48

Decompiled Minecraft 26.3 source of DebugQueryHandler (net/minecraft/client/DebugQueryHandler.java) with Mojang official mappings, stored verbatim on the site.