WrappedGoal .java

net.minecraft.world.entity.ai.goal.WrappedGoal (class): members: canBeReplacedBy, getPriority, getGoal, goal, adjustedTickDelay, getFlags, setFlags, stop.

net.minecraft.world.entity.ai.goalclass102 linescommonextends Goal1.9 KB

API Surface (16)

boolean canBeReplacedBy(final WrappedGoal goal)
boolean canUse()
boolean canContinueToUse()
boolean isInterruptable()
void start()
void stop()
boolean requiresUpdateEveryTick()
int adjustedTickDelay(final int ticks)
void tick()
void setFlags(final EnumSet<Goal.Flag> requiredControlFlags)
EnumSet<Goal.Flag> getFlags()
boolean isRunning()
int getPriority()
Goal getGoal()
boolean equals(final @Nullable Object o)
int hashCode()

Fields & Constants (3)

goal
priority
isRunning

Code Graph: Dependencies (1)

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

Full Source

WrappedGoal.java102 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import java.util.EnumSet;
4
import org.jspecify.annotations.Nullable;
5
6
public class WrappedGoal extends Goal {
7
	private final Goal goal;
8
	private final int priority;
9
	private boolean isRunning;
10
11
	public WrappedGoal(final int priority, final Goal goal) {
12
		this.priority = priority;
13
		this.goal = goal;
14
	}
15
16
	public boolean canBeReplacedBy(final WrappedGoal goal) {
17
		return this.isInterruptable() && goal.getPriority() < this.getPriority();
18
	}
19
20
	@Override
21
	public boolean canUse() {
22
		return this.goal.canUse();
23
	}
24
25
	@Override
26
	public boolean canContinueToUse() {
27
		return this.goal.canContinueToUse();
28
	}
29
30
	@Override
31
	public boolean isInterruptable() {
32
		return this.goal.isInterruptable();
33
	}
34
35
	@Override
36
	public void start() {
37
		if (!this.isRunning) {
38
			this.isRunning = true;
39
			this.goal.start();
40
		}
41
	}
42
43
	@Override
44
	public void stop() {
45
		if (this.isRunning) {
46
			this.isRunning = false;
47
			this.goal.stop();
48
		}
49
	}
50
51
	@Override
52
	public boolean requiresUpdateEveryTick() {
53
		return this.goal.requiresUpdateEveryTick();
54
	}
55
56
	@Override
57
	protected int adjustedTickDelay(final int ticks) {
58
		return this.goal.adjustedTickDelay(ticks);
59
	}
60
61
	@Override
62
	public void tick() {
63
		this.goal.tick();
64
	}
65
66
	@Override
67
	public void setFlags(final EnumSet<Goal.Flag> requiredControlFlags) {
68
		this.goal.setFlags(requiredControlFlags);
69
	}
70
71
	@Override
72
	public EnumSet<Goal.Flag> getFlags() {
73
		return this.goal.getFlags();
74
	}
75
76
	public boolean isRunning() {
77
		return this.isRunning;
78
	}
79
80
	public int getPriority() {
81
		return this.priority;
82
	}
83
84
	public Goal getGoal() {
85
		return this.goal;
86
	}
87
88
	@Override
89
	public boolean equals(final @Nullable Object o) {
90
		if (this == o) {
91
			return true;
92
		} else {
93
			return o != null && this.getClass() == o.getClass() ? this.goal.equals(((WrappedGoal)o).goal) : false;
94
		}
95
	}
96
97
	@Override
98
	public int hashCode() {
99
		return this.goal.hashCode();
100
	}
101
}
102

Decompiled Minecraft 26.3 source of WrappedGoal (net/minecraft/world/entity/ai/goal/WrappedGoal.java) with Mojang official mappings, stored verbatim on the site.