Package net.minecraft.entity.ai.goal
Class GoalSelector
java.lang.Object
net.minecraft.entity.ai.goal.GoalSelector
public class GoalSelector extends Object
Manages a set of goals, which are competing for certain controls on the mob.
Multiple goals can run at the same time, so long as they are all using different controls.
A running goal will always be replaced with a goal with a lower priority, if
such a goal exists, it's competing for the same control and its
canStart()
method returns true. (Note that some goals randomize
this method.)
If two goals have the same priority and are competing for the same control, then one goal cannot replace the other if it's running. The goal selector tries to run goals in the order they were added.
-
Field Summary
Fields Modifier and Type Field Description private EnumSet<Goal.Control>
disabledControls
private Set<PrioritizedGoal>
goals
private Map<Goal.Control,PrioritizedGoal>
goalsByControl
private static Logger
LOGGER
private Supplier<Profiler>
profiler
private static PrioritizedGoal
REPLACEABLE_GOAL
private int
timeInterval
-
Constructor Summary
Constructors Constructor Description GoalSelector(Supplier<Profiler> profiler)
-
Method Summary
Modifier and Type Method Description void
add(int priority, Goal goal)
Adds a goal with a certain priority.void
disableControl(Goal.Control control)
void
enableControl(Goal.Control control)
Stream<PrioritizedGoal>
getRunningGoals()
void
remove(Goal goal)
void
setControlEnabled(Goal.Control control, boolean enabled)
void
tick()
-
Field Details
-
LOGGER
-
REPLACEABLE_GOAL
-
goalsByControl
-
goals
-
profiler
-
disabledControls
-
timeInterval
private int timeInterval
-
-
Constructor Details
-
GoalSelector
-
-
Method Details
-
add
Adds a goal with a certain priority. Goals with lower priorities will replace running goals with a higher priority. -
remove
-
tick
public void tick() -
getRunningGoals
-
disableControl
-
enableControl
-
setControlEnabled
-