Package net.minecraft.entity.ai.brain
Class Brain<E extends LivingEntity>
java.lang.Object
net.minecraft.entity.ai.brain.Brain<E>
public class Brain<E extends LivingEntity> extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Brain.MemoryEntry<U>
static class
Brain.Profile<E extends LivingEntity>
A simple profile of a brain. -
Field Summary
Fields Modifier and Type Field Description private long
activityStartTime
private Supplier<com.mojang.serialization.Codec<Brain<E>>>
codecSupplier
private Set<Activity>
coreActivities
private Activity
defaultActivity
private Map<Activity,Set<MemoryModuleType<?>>>
forgettingActivityMemories
The map from activities to the memories to forget after the activity is completed.private static Logger
LOGGER
private Map<MemoryModuleType<?>,Optional<? extends Memory<?>>>
memories
private Set<Activity>
possibleActivities
private Map<Activity,Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>>>
requiredActivityMemories
private Schedule
schedule
private Map<SensorType<? extends Sensor<? super E>>,Sensor<? super E>>
sensors
private Map<Integer,Map<Activity,Set<Task<? super E>>>>
tasks
-
Constructor Summary
Constructors Constructor Description Brain(Collection<? extends MemoryModuleType<?>> memories, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors, ImmutableList<Brain.MemoryEntry<?>> memoryEntries, Supplier<com.mojang.serialization.Codec<Brain<E>>> codecSupplier)
-
Method Summary
Modifier and Type Method Description private boolean
canDoActivity(Activity activity)
Brain<E>
copy()
static <E extends LivingEntity>
com.mojang.serialization.Codec<Brain<E>>createBrainCodec(Collection<? extends MemoryModuleType<?>> memoryModules, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors)
static <E extends LivingEntity>
Brain.Profile<E>createProfile(Collection<? extends MemoryModuleType<?>> memoryModules, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors)
void
doExclusively(Activity activity)
<T> com.mojang.serialization.DataResult<T>
encode(com.mojang.serialization.DynamicOps<T> ops)
<U> void
forget(MemoryModuleType<U> type)
private void
forgetIrrelevantMemories(Activity except)
Optional<Activity>
getFirstPossibleNonCoreActivity()
<U> Optional<U>
getOptionalMemory(MemoryModuleType<U> type)
List<Task<? super E>>
getRunningTasks()
Deprecated.Schedule
getSchedule()
boolean
hasActivity(Activity activity)
boolean
hasMemoryModule(MemoryModuleType<?> type)
(package private) ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>>
indexTaskList(int begin, ImmutableList<? extends Task<? super E>> tasks)
private boolean
isEmptyCollection(Object value)
boolean
isMemoryInState(MemoryModuleType<?> type, MemoryModuleState state)
<U> boolean
method_29519(MemoryModuleType<U> memoryModuleType, U u)
void
refreshActivities(long timeOfDay, long time)
<U> void
remember(MemoryModuleType<U> type, Optional<? extends U> value)
<U> void
remember(MemoryModuleType<U> type, U value)
<U> void
remember(MemoryModuleType<U> type, U value, long startTime)
void
resetPossibleActivities()
void
resetPossibleActivities(List<Activity> list)
private void
resetPossibleActivities(Activity except)
void
setCoreActivities(Set<Activity> coreActivities)
void
setDefaultActivity(Activity activity)
private <U> void
setMemory(MemoryModuleType<U> type, Optional<? extends Memory<?>> memory)
void
setSchedule(Schedule schedule)
void
setTaskList(Activity activity, int begin, ImmutableList<? extends Task<? super E>> list)
void
setTaskList(Activity activity, int begin, ImmutableList<? extends Task<? super E>> tasks, MemoryModuleType<?> memoryType)
void
setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks)
void
setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>> requiredMemories)
private void
setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>> requiredMemories, Set<MemoryModuleType<?>> forgettingMemories)
private void
startTasks(ServerWorld world, E entity)
void
stopAllTasks(ServerWorld world, E entity)
private Stream<Brain.MemoryEntry<?>>
streamMemories()
void
tick(ServerWorld world, E entity)
private void
tickMemories()
private void
tickSensors(ServerWorld world, E entity)
private void
updateTasks(ServerWorld world, E entity)
-
Field Details
-
LOGGER
-
codecSupplier
-
memories
-
sensors
private final Map<SensorType<? extends Sensor<? super E extends LivingEntity>>,Sensor<? super E extends LivingEntity>> sensors -
tasks
-
schedule
-
requiredActivityMemories
private final Map<Activity,Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>>> requiredActivityMemories -
forgettingActivityMemories
The map from activities to the memories to forget after the activity is completed. -
coreActivities
-
possibleActivities
-
defaultActivity
-
activityStartTime
private long activityStartTime
-
-
Constructor Details
-
Brain
public Brain(Collection<? extends MemoryModuleType<?>> memories, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors, ImmutableList<Brain.MemoryEntry<?>> memoryEntries, Supplier<com.mojang.serialization.Codec<Brain<E>>> codecSupplier)
-
-
Method Details
-
createProfile
public static <E extends LivingEntity> Brain.Profile<E> createProfile(Collection<? extends MemoryModuleType<?>> memoryModules, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors) -
createBrainCodec
public static <E extends LivingEntity> com.mojang.serialization.Codec<Brain<E>> createBrainCodec(Collection<? extends MemoryModuleType<?>> memoryModules, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors) -
encode
public <T> com.mojang.serialization.DataResult<T> encode(com.mojang.serialization.DynamicOps<T> ops) -
streamMemories
-
hasMemoryModule
-
forget
-
remember
-
remember
-
remember
-
setMemory
-
getOptionalMemory
-
method_29519
-
isMemoryInState
-
getSchedule
-
setSchedule
-
setCoreActivities
-
getRunningTasks
Deprecated. -
resetPossibleActivities
public void resetPossibleActivities() -
getFirstPossibleNonCoreActivity
-
doExclusively
-
resetPossibleActivities
-
forgetIrrelevantMemories
-
refreshActivities
public void refreshActivities(long timeOfDay, long time) -
resetPossibleActivities
-
setDefaultActivity
-
setTaskList
public void setTaskList(Activity activity, int begin, ImmutableList<? extends Task<? super E>> list) -
setTaskList
public void setTaskList(Activity activity, int begin, ImmutableList<? extends Task<? super E>> tasks, MemoryModuleType<?> memoryType) -
setTaskList
public void setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks) -
setTaskList
public void setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>> requiredMemories) -
setTaskList
private void setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>> requiredMemories, Set<MemoryModuleType<?>> forgettingMemories) -
hasActivity
-
copy
-
tick
-
tickSensors
-
tickMemories
private void tickMemories() -
stopAllTasks
-
startTasks
-
updateTasks
-
canDoActivity
-
isEmptyCollection
-
indexTaskList
ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexTaskList(int begin, ImmutableList<? extends Task<? super E>> tasks)- Parameters:
begin
- The beginning of the index of tasks, exclusive
-