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 java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Brain.BrainCodec<E extends LivingEntity>
(package private) static class
Brain.MemoryCodec<U>
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<Activity>
activeActivities
private java.util.Map<Activity,java.util.Set<MemoryModuleType<?>>>
activityMemoriesToEraseWhenStopped
private java.util.Map<Activity,java.util.Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleStatus>>>
activityRequirements
private java.util.Map<java.lang.Integer,java.util.Map<Activity,java.util.Set<Task<? super E>>>>
availableBehaviorsByPriority
private java.util.function.Supplier<com.mojang.serialization.Codec<Brain<E>>>
codec
private java.util.Set<Activity>
coreActivities
private Activity
defaultActivity
private long
lastScheduleUpdate
private static org.apache.logging.log4j.Logger
LOGGER
private java.util.Map<MemoryModuleType<?>,java.util.Optional<? extends Memory<?>>>
memories
private Schedule
schedule
private java.util.Map<SensorType<? extends Sensor<? super E>>,Sensor<? super E>>
sensors
-
Constructor Summary
Constructors Constructor Description Brain(java.util.Collection<? extends MemoryModuleType<?>> p_i231494_1_, java.util.Collection<? extends SensorType<? extends Sensor<? super E>>> p_i231494_2_, com.google.common.collect.ImmutableList<Brain.MemoryCodec<?>> p_i231494_3_, java.util.function.Supplier<com.mojang.serialization.Codec<Brain<E>>> p_i231494_4_)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private boolean
activityRequirementsAreMet(Activity p_218217_1_)
void
addActivity(Activity p_233698_1_, int p_233698_2_, com.google.common.collect.ImmutableList<? extends Task<? super E>> p_233698_3_)
void
addActivity(Activity p_218208_1_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>> p_218208_2_)
private void
addActivityAndRemoveMemoriesWhenStopped(Activity p_233701_1_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>> p_233701_2_, java.util.Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleStatus>> p_233701_3_, java.util.Set<MemoryModuleType<?>> p_233701_4_)
void
addActivityAndRemoveMemoryWhenStopped(Activity p_233699_1_, int p_233699_2_, com.google.common.collect.ImmutableList<? extends Task<? super E>> p_233699_3_, MemoryModuleType<?> p_233699_4_)
void
addActivityWithConditions(Activity p_233700_1_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>> p_233700_2_, java.util.Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleStatus>> p_233700_3_)
boolean
checkMemory(MemoryModuleType<?> p_218196_1_, MemoryModuleStatus p_218196_2_)
static <E extends LivingEntity>
com.mojang.serialization.Codec<Brain<E>>codec(java.util.Collection<? extends MemoryModuleType<?>> p_233710_0_, java.util.Collection<? extends SensorType<? extends Sensor<? super E>>> p_233710_1_)
Brain<E>
copyWithoutBehaviors()
(package private) com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>>
createPriorityPairs(int p_233692_1_, com.google.common.collect.ImmutableList<? extends Task<? super E>> p_233692_2_)
private void
eraseMemoriesForOtherActivitesThan(Activity p_233715_1_)
<U> void
eraseMemory(MemoryModuleType<U> p_218189_1_)
private void
forgetOutdatedMemories()
java.util.Optional<Activity>
getActiveNonCoreActivity()
<U> java.util.Optional<U>
getMemory(MemoryModuleType<U> p_218207_1_)
java.util.List<Task<? super E>>
getRunningBehaviors()
Deprecated.Schedule
getSchedule()
boolean
hasMemoryValue(MemoryModuleType<?> p_218191_1_)
boolean
isActive(Activity p_218214_1_)
private boolean
isEmptyCollection(java.lang.Object p_218213_1_)
<U> boolean
isMemoryValue(MemoryModuleType<U> p_233708_1_, U p_233708_2_)
private java.util.stream.Stream<Brain.MemoryCodec<?>>
memories()
static <E extends LivingEntity>
Brain.BrainCodec<E>provider(java.util.Collection<? extends MemoryModuleType<?>> p_233705_0_, java.util.Collection<? extends SensorType<? extends Sensor<? super E>>> p_233705_1_)
<T> com.mojang.serialization.DataResult<T>
serializeStart(com.mojang.serialization.DynamicOps<T> p_233702_1_)
private void
setActiveActivity(Activity p_233713_1_)
void
setActiveActivityIfPossible(Activity p_218202_1_)
void
setActiveActivityToFirstValid(java.util.List<Activity> p_233706_1_)
void
setCoreActivities(java.util.Set<Activity> p_218199_1_)
void
setDefaultActivity(Activity p_218200_1_)
<U> void
setMemory(MemoryModuleType<U> p_218226_1_, java.util.Optional<? extends U> p_218226_2_)
<U> void
setMemory(MemoryModuleType<U> p_218205_1_, U p_218205_2_)
private <U> void
setMemoryInternal(MemoryModuleType<U> p_233709_1_, java.util.Optional<? extends Memory<?>> p_233709_2_)
<U> void
setMemoryWithExpiry(MemoryModuleType<U> p_233696_1_, U p_233696_2_, long p_233696_3_)
void
setSchedule(Schedule p_218203_1_)
private void
startEachNonRunningBehavior(ServerWorld p_218218_1_, E p_218218_2_)
void
stopAll(ServerWorld p_218227_1_, E p_218227_2_)
void
tick(ServerWorld p_218210_1_, E p_218210_2_)
private void
tickEachRunningBehavior(ServerWorld p_218222_1_, E p_218222_2_)
private void
tickSensors(ServerWorld p_233711_1_, E p_233711_2_)
void
updateActivityFromSchedule(long p_218211_1_, long p_218211_3_)
void
useDefaultActivity()
-
-
-
Field Detail
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER
-
codec
private final java.util.function.Supplier<com.mojang.serialization.Codec<Brain<E extends LivingEntity>>> codec
-
memories
private final java.util.Map<MemoryModuleType<?>,java.util.Optional<? extends Memory<?>>> memories
-
sensors
private final java.util.Map<SensorType<? extends Sensor<? super E extends LivingEntity>>,Sensor<? super E extends LivingEntity>> sensors
-
availableBehaviorsByPriority
private final java.util.Map<java.lang.Integer,java.util.Map<Activity,java.util.Set<Task<? super E extends LivingEntity>>>> availableBehaviorsByPriority
-
schedule
private Schedule schedule
-
activityRequirements
private final java.util.Map<Activity,java.util.Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleStatus>>> activityRequirements
-
activityMemoriesToEraseWhenStopped
private final java.util.Map<Activity,java.util.Set<MemoryModuleType<?>>> activityMemoriesToEraseWhenStopped
-
coreActivities
private java.util.Set<Activity> coreActivities
-
activeActivities
private final java.util.Set<Activity> activeActivities
-
defaultActivity
private Activity defaultActivity
-
lastScheduleUpdate
private long lastScheduleUpdate
-
-
Constructor Detail
-
Brain
public Brain(java.util.Collection<? extends MemoryModuleType<?>> p_i231494_1_, java.util.Collection<? extends SensorType<? extends Sensor<? super E>>> p_i231494_2_, com.google.common.collect.ImmutableList<Brain.MemoryCodec<?>> p_i231494_3_, java.util.function.Supplier<com.mojang.serialization.Codec<Brain<E>>> p_i231494_4_)
-
-
Method Detail
-
provider
public static <E extends LivingEntity> Brain.BrainCodec<E> provider(java.util.Collection<? extends MemoryModuleType<?>> p_233705_0_, java.util.Collection<? extends SensorType<? extends Sensor<? super E>>> p_233705_1_)
-
codec
public static <E extends LivingEntity> com.mojang.serialization.Codec<Brain<E>> codec(java.util.Collection<? extends MemoryModuleType<?>> p_233710_0_, java.util.Collection<? extends SensorType<? extends Sensor<? super E>>> p_233710_1_)
-
serializeStart
public <T> com.mojang.serialization.DataResult<T> serializeStart(com.mojang.serialization.DynamicOps<T> p_233702_1_)
-
memories
private java.util.stream.Stream<Brain.MemoryCodec<?>> memories()
-
hasMemoryValue
public boolean hasMemoryValue(MemoryModuleType<?> p_218191_1_)
-
eraseMemory
public <U> void eraseMemory(MemoryModuleType<U> p_218189_1_)
-
setMemory
public <U> void setMemory(MemoryModuleType<U> p_218205_1_, @Nullable U p_218205_2_)
-
setMemoryWithExpiry
public <U> void setMemoryWithExpiry(MemoryModuleType<U> p_233696_1_, U p_233696_2_, long p_233696_3_)
-
setMemory
public <U> void setMemory(MemoryModuleType<U> p_218226_1_, java.util.Optional<? extends U> p_218226_2_)
-
setMemoryInternal
private <U> void setMemoryInternal(MemoryModuleType<U> p_233709_1_, java.util.Optional<? extends Memory<?>> p_233709_2_)
-
getMemory
public <U> java.util.Optional<U> getMemory(MemoryModuleType<U> p_218207_1_)
-
isMemoryValue
public <U> boolean isMemoryValue(MemoryModuleType<U> p_233708_1_, U p_233708_2_)
-
checkMemory
public boolean checkMemory(MemoryModuleType<?> p_218196_1_, MemoryModuleStatus p_218196_2_)
-
getSchedule
public Schedule getSchedule()
-
setSchedule
public void setSchedule(Schedule p_218203_1_)
-
setCoreActivities
public void setCoreActivities(java.util.Set<Activity> p_218199_1_)
-
getRunningBehaviors
@Deprecated public java.util.List<Task<? super E>> getRunningBehaviors()
Deprecated.
-
useDefaultActivity
public void useDefaultActivity()
-
getActiveNonCoreActivity
public java.util.Optional<Activity> getActiveNonCoreActivity()
-
setActiveActivityIfPossible
public void setActiveActivityIfPossible(Activity p_218202_1_)
-
setActiveActivity
private void setActiveActivity(Activity p_233713_1_)
-
eraseMemoriesForOtherActivitesThan
private void eraseMemoriesForOtherActivitesThan(Activity p_233715_1_)
-
updateActivityFromSchedule
public void updateActivityFromSchedule(long p_218211_1_, long p_218211_3_)
-
setActiveActivityToFirstValid
public void setActiveActivityToFirstValid(java.util.List<Activity> p_233706_1_)
-
setDefaultActivity
public void setDefaultActivity(Activity p_218200_1_)
-
addActivity
public void addActivity(Activity p_233698_1_, int p_233698_2_, com.google.common.collect.ImmutableList<? extends Task<? super E>> p_233698_3_)
-
addActivityAndRemoveMemoryWhenStopped
public void addActivityAndRemoveMemoryWhenStopped(Activity p_233699_1_, int p_233699_2_, com.google.common.collect.ImmutableList<? extends Task<? super E>> p_233699_3_, MemoryModuleType<?> p_233699_4_)
-
addActivity
public void addActivity(Activity p_218208_1_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>> p_218208_2_)
-
addActivityWithConditions
public void addActivityWithConditions(Activity p_233700_1_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>> p_233700_2_, java.util.Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleStatus>> p_233700_3_)
-
addActivityAndRemoveMemoriesWhenStopped
private void addActivityAndRemoveMemoriesWhenStopped(Activity p_233701_1_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<java.lang.Integer,? extends Task<? super E>>> p_233701_2_, java.util.Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryModuleStatus>> p_233701_3_, java.util.Set<MemoryModuleType<?>> p_233701_4_)
-
isActive
public boolean isActive(Activity p_218214_1_)
-
tick
public void tick(ServerWorld p_218210_1_, E p_218210_2_)
-
tickSensors
private void tickSensors(ServerWorld p_233711_1_, E p_233711_2_)
-
forgetOutdatedMemories
private void forgetOutdatedMemories()
-
stopAll
public void stopAll(ServerWorld p_218227_1_, E p_218227_2_)
-
startEachNonRunningBehavior
private void startEachNonRunningBehavior(ServerWorld p_218218_1_, E p_218218_2_)
-
tickEachRunningBehavior
private void tickEachRunningBehavior(ServerWorld p_218222_1_, E p_218222_2_)
-
activityRequirementsAreMet
private boolean activityRequirementsAreMet(Activity p_218217_1_)
-
isEmptyCollection
private boolean isEmptyCollection(java.lang.Object p_218213_1_)
-
-