public class Brain<E extends LivingEntity> extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Brain.MemoryEntry<U> |
static class |
Brain.Profile<E extends LivingEntity>
A simple profile of a brain.
|
Modifier and Type | Field and 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 and 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) |
Modifier and Type | Method and Description |
---|---|
private boolean |
canDoActivity(Activity activity) |
Brain<E> |
copy() |
static <E extends LivingEntity> |
createBrainCodec(Collection<? extends MemoryModuleType<?>> memoryModules,
Collection<? extends SensorType<? extends Sensor<? super E>>> sensors) |
static <E extends LivingEntity> |
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() |
private void |
resetPossibleActivities(Activity except) |
void |
resetPossibleActivities(List<Activity> list) |
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,
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) |
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) |
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) |
private static final Logger LOGGER
private final Supplier<com.mojang.serialization.Codec<Brain<E extends LivingEntity>>> codecSupplier
private final Map<MemoryModuleType<?>,Optional<? extends Memory<?>>> memories
private final Map<SensorType<? extends Sensor<? super E extends LivingEntity>>,Sensor<? super E extends LivingEntity>> sensors
private Schedule schedule
private final Map<Activity,Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleState>>> requiredActivityMemories
private final Map<Activity,Set<MemoryModuleType<?>>> forgettingActivityMemories
private Activity defaultActivity
private long activityStartTime
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)
public static <E extends LivingEntity> Brain.Profile<E> createProfile(Collection<? extends MemoryModuleType<?>> memoryModules, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors)
public static <E extends LivingEntity> com.mojang.serialization.Codec<Brain<E>> createBrainCodec(Collection<? extends MemoryModuleType<?>> memoryModules, Collection<? extends SensorType<? extends Sensor<? super E>>> sensors)
public <T> com.mojang.serialization.DataResult<T> encode(com.mojang.serialization.DynamicOps<T> ops)
private Stream<Brain.MemoryEntry<?>> streamMemories()
public boolean hasMemoryModule(MemoryModuleType<?> type)
public <U> void forget(MemoryModuleType<U> type)
public <U> void remember(MemoryModuleType<U> type, @Nullable U value)
public <U> void remember(MemoryModuleType<U> type, U value, long startTime)
public <U> void remember(MemoryModuleType<U> type, Optional<? extends U> value)
private <U> void setMemory(MemoryModuleType<U> type, Optional<? extends Memory<?>> memory)
public <U> Optional<U> getOptionalMemory(MemoryModuleType<U> type)
public <U> boolean method_29519(MemoryModuleType<U> memoryModuleType, U u)
public boolean isMemoryInState(MemoryModuleType<?> type, MemoryModuleState state)
public Schedule getSchedule()
public void setSchedule(Schedule schedule)
@Deprecated public List<Task<? super E>> getRunningTasks()
public void resetPossibleActivities()
public void doExclusively(Activity activity)
private void resetPossibleActivities(Activity except)
private void forgetIrrelevantMemories(Activity except)
public void refreshActivities(long timeOfDay, long time)
public void setDefaultActivity(Activity activity)
public void setTaskList(Activity activity, int begin, ImmutableList<? extends Task<? super E>> list)
public void setTaskList(Activity activity, int begin, ImmutableList<? extends Task<? super E>> tasks, MemoryModuleType<?> memoryType)
public void setTaskList(Activity activity, ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexedTasks)
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)
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)
public boolean hasActivity(Activity activity)
public void tick(ServerWorld world, E entity)
private void tickSensors(ServerWorld world, E entity)
private void tickMemories()
public void stopAllTasks(ServerWorld world, E entity)
private void startTasks(ServerWorld world, E entity)
private void updateTasks(ServerWorld world, E entity)
private boolean canDoActivity(Activity activity)
private boolean isEmptyCollection(Object value)
ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Task<? super E>>> indexTaskList(int begin, ImmutableList<? extends Task<? super E>> tasks)
begin
- The beginning of the index of tasks, exclusive