FieldTree .java

net.minecraft.nbt.visitors.FieldTree (record): members: depth, selectedFields, fieldsToRecurse, createRoot, isSelected, addEntry. imports: TagType.

net.minecraft.nbt.visitorsrecord28 linescommon822 B

API Surface (4)

record FieldTree(int depth, Map<String, TagType<?>> selectedFields, Map<String, FieldTree> fieldsToRecurse)
FieldTree createRoot()
void addEntry(final FieldSelector field)
boolean isSelected(final TagType<?> type, final String id)

Code Graph: Dependencies (2)

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

Full Source

FieldTree.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.nbt.visitors;
2
3
import java.util.HashMap;
4
import java.util.Map;
5
import net.minecraft.nbt.TagType;
6
7
public record FieldTree(int depth, Map<String, TagType<?>> selectedFields, Map<String, FieldTree> fieldsToRecurse) {
8
	private FieldTree(final int depth) {
9
		this(depth, new HashMap<>(), new HashMap<>());
10
	}
11
12
	public static FieldTree createRoot() {
13
		return new FieldTree(1);
14
	}
15
16
	public void addEntry(final FieldSelector field) {
17
		if (this.depth <= field.path().size()) {
18
			this.fieldsToRecurse.computeIfAbsent(field.path().get(this.depth - 1), s -> new FieldTree(this.depth + 1)).addEntry(field);
19
		} else {
20
			this.selectedFields.put(field.name(), field.type());
21
		}
22
	}
23
24
	public boolean isSelected(final TagType<?> type, final String id) {
25
		return type.equals(this.selectedFields().get(id));
26
	}
27
}
28

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