API Surface (2) StreamTagVisitor.EntryResult visitEntry(final TagType<?> type, final String id)
StreamTagVisitor.ValueResult visitContainerEnd()
Code Graph: Dependencies (5) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
SkipFields.java 48 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.nbt.visitors;
2
3 import java.util.ArrayDeque;
4 import java.util.Deque;
5 import net.minecraft.nbt.CompoundTag;
6 import net.minecraft.nbt.StreamTagVisitor;
7 import net.minecraft.nbt.TagType;
8
9 public class SkipFields extends CollectToTag {
10 private final Deque<FieldTree> stack = new ArrayDeque<>();
11
12 public SkipFields(final FieldSelector... wantedFields) {
13 FieldTree rootFrame = FieldTree.createRoot();
14
15 for (FieldSelector wantedField : wantedFields) {
16 rootFrame.addEntry(wantedField);
17 }
18
19 this.stack.push(rootFrame);
20 }
21
22 @Override
23 public StreamTagVisitor.EntryResult visitEntry(final TagType<?> type, final String id) {
24 FieldTree currentFrame = this.stack.element();
25 if (currentFrame.isSelected(type, id)) {
26 return StreamTagVisitor.EntryResult.SKIP;
27 }
28
29 if (type == CompoundTag.TYPE) {
30 FieldTree newFrame = currentFrame.fieldsToRecurse().get(id);
31 if (newFrame != null) {
32 this.stack.push(newFrame);
33 }
34 }
35
36 return super.visitEntry(type, id);
37 }
38
39 @Override
40 public StreamTagVisitor.ValueResult visitContainerEnd() {
41 if (this.depth() == this.stack.element().depth()) {
42 this.stack.pop();
43 }
44
45 return super.visitContainerEnd();
46 }
47 }
48
Decompiled Minecraft 26.3 source of SkipFields (net/minecraft/nbt/visitors/SkipFields.java) with Mojang official mappings, stored verbatim on the site.