Package com.minecolonies.api.entity
Class CustomGoalSelector
java.lang.Object
net.minecraft.world.entity.ai.goal.GoalSelector
com.minecolonies.api.entity.CustomGoalSelector
public class CustomGoalSelector
extends net.minecraft.world.entity.ai.goal.GoalSelector
A simplified goal selector, for more performance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionSet<net.minecraft.world.entity.ai.goal.WrappedGoal>All goals added to this selectorFields inherited from class net.minecraft.world.entity.ai.goal.GoalSelector
disabledFlags, lockedFlags -
Constructor Summary
ConstructorsConstructorDescriptionCustomGoalSelector(@NotNull Supplier<net.minecraft.util.profiling.ProfilerFiller> profiler) Creates a new customgoalselector with the given profiler.CustomGoalSelector(@NotNull net.minecraft.world.entity.ai.goal.GoalSelector old) Create a new goalselector from an existing one, simply re-uses the references. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGoal(int priority, net.minecraft.world.entity.ai.goal.Goal task) Add a now AITask.voiddisableControlFlag(net.minecraft.world.entity.ai.goal.Goal.Flag flag) Disables the given flagvoidenableControlFlag(net.minecraft.world.entity.ai.goal.Goal.Flag flag) Enables the given flagStream<net.minecraft.world.entity.ai.goal.WrappedGoal>Gets all goals currently runningvoidimportFrom(net.minecraft.world.entity.ai.goal.GoalSelector selector) Imports values from another selectorvoidremoveGoal(net.minecraft.world.entity.ai.goal.Goal task) removes the indicated task from the entity's AI tasks.voidsetControlFlag(net.minecraft.world.entity.ai.goal.Goal.Flag flag, boolean enabled) Sets the flag to enabled or disabledvoidtick()Ticks this selector, first checks running goals to stop, then checks all goals to see which should start running.Methods inherited from class net.minecraft.world.entity.ai.goal.GoalSelector
getAvailableGoals, removeAllGoals, setNewGoalRate, tickRunningGoals
-
Field Details
-
availableGoals
All goals added to this selector
-
-
Constructor Details
-
CustomGoalSelector
public CustomGoalSelector(@NotNull @NotNull net.minecraft.world.entity.ai.goal.GoalSelector old) Create a new goalselector from an existing one, simply re-uses the references.- Parameters:
old- the old selector to use
-
CustomGoalSelector
public CustomGoalSelector(@NotNull @NotNull Supplier<net.minecraft.util.profiling.ProfilerFiller> profiler) Creates a new customgoalselector with the given profiler.- Parameters:
profiler- the profiler to use, usually attached to a world object
-
-
Method Details
-
importFrom
public void importFrom(net.minecraft.world.entity.ai.goal.GoalSelector selector) Imports values from another selector- Parameters:
selector- selector to import from
-
addGoal
public void addGoal(int priority, net.minecraft.world.entity.ai.goal.Goal task) Add a now AITask. Args : priority, task- Overrides:
addGoalin classnet.minecraft.world.entity.ai.goal.GoalSelector
-
removeGoal
public void removeGoal(net.minecraft.world.entity.ai.goal.Goal task) removes the indicated task from the entity's AI tasks.- Overrides:
removeGoalin classnet.minecraft.world.entity.ai.goal.GoalSelector
-
tick
public void tick()Ticks this selector, first checks running goals to stop, then checks all goals to see which should start running. Finally ticks all running goals Performance wise this is about 6 times faster, when checking at the same rate as the vanilla one, resulting in about 3-4 times less time spent updating and executing AI goals. When updating non-running goals only every 4 ticks it goes up to about 10% of vanilla's time spent for the whole update goals and their execution.- Overrides:
tickin classnet.minecraft.world.entity.ai.goal.GoalSelector
-
getRunningGoals
Gets all goals currently running- Overrides:
getRunningGoalsin classnet.minecraft.world.entity.ai.goal.GoalSelector- Returns:
- the stream of running goals.
-
disableControlFlag
public void disableControlFlag(net.minecraft.world.entity.ai.goal.Goal.Flag flag) Disables the given flag- Overrides:
disableControlFlagin classnet.minecraft.world.entity.ai.goal.GoalSelector- Parameters:
flag- the flag to disable.
-
enableControlFlag
public void enableControlFlag(net.minecraft.world.entity.ai.goal.Goal.Flag flag) Enables the given flag- Overrides:
enableControlFlagin classnet.minecraft.world.entity.ai.goal.GoalSelector- Parameters:
flag- the flag to enable.
-
setControlFlag
public void setControlFlag(net.minecraft.world.entity.ai.goal.Goal.Flag flag, boolean enabled) Sets the flag to enabled or disabled- Overrides:
setControlFlagin classnet.minecraft.world.entity.ai.goal.GoalSelector- Parameters:
flag- Flag to setenabled- enable or disable it
-