AdvancementNode .java

net.minecraft.advancements.AdvancementNode (class): members: setLocation, isTask, advancement, isRoot, holder, getRoot, addChild, root, children, parent.

net.minecraft.advancementsclass95 linescommon1.9 KB

API Surface (14)

Advancement advancement()
AdvancementHolder holder()
boolean isTask()
boolean isRoot()
AdvancementNode root()
AdvancementNode getRoot(final AdvancementNode advancement)
Iterable<AdvancementNode> children()
void addChild(final AdvancementNode child)
void setLocation(final float x, final float y)
float x()
float y()
boolean equals(final Object obj)
int hashCode()
String toString()

Fields & Constants (5)

holder
parent
children
x
y

Code Graph: Dependencies (2)

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

Full Source

AdvancementNode.java95 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.advancements;
2
3
import com.google.common.annotations.VisibleForTesting;
4
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
5
import java.util.Set;
6
import org.jspecify.annotations.Nullable;
7
8
public class AdvancementNode {
9
	private final AdvancementHolder holder;
10
	private final @Nullable AdvancementNode parent;
11
	private final Set<AdvancementNode> children = new ReferenceOpenHashSet<>();
12
	private float x;
13
	private float y;
14
15
	@VisibleForTesting
16
	public AdvancementNode(final AdvancementHolder holder, final @Nullable AdvancementNode parent) {
17
		this.holder = holder;
18
		this.parent = parent;
19
	}
20
21
	public Advancement advancement() {
22
		return this.holder.value();
23
	}
24
25
	public AdvancementHolder holder() {
26
		return this.holder;
27
	}
28
29
	public boolean isTask() {
30
		return this.parent != null;
31
	}
32
33
	public boolean isRoot() {
34
		return this.parent == null;
35
	}
36
37
	public @Nullable AdvancementNode parent() {
38
		return this.parent;
39
	}
40
41
	public AdvancementNode root() {
42
		return getRoot(this);
43
	}
44
45
	public static AdvancementNode getRoot(final AdvancementNode advancement) {
46
		AdvancementNode root = advancement;
47
48
		while (true) {
49
			AdvancementNode parent = root.parent();
50
			if (parent == null) {
51
				return root;
52
			}
53
54
			root = parent;
55
		}
56
	}
57
58
	public Iterable<AdvancementNode> children() {
59
		return this.children;
60
	}
61
62
	@VisibleForTesting
63
	public void addChild(final AdvancementNode child) {
64
		this.children.add(child);
65
	}
66
67
	public void setLocation(final float x, final float y) {
68
		this.x = x;
69
		this.y = y;
70
	}
71
72
	public float x() {
73
		return this.x;
74
	}
75
76
	public float y() {
77
		return this.y;
78
	}
79
80
	@Override
81
	public boolean equals(final Object obj) {
82
		return this == obj ? true : obj instanceof AdvancementNode that && this.holder.equals(that.holder);
83
	}
84
85
	@Override
86
	public int hashCode() {
87
		return this.holder.hashCode();
88
	}
89
90
	@Override
91
	public String toString() {
92
		return this.holder.id().toString();
93
	}
94
}
95

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