Package net.minecraft.world.entity.ai
Class Brain<E extends LivingEntity>
java.lang.Object
net.minecraft.world.entity.ai.Brain<E>
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
static class
Brain.Provider<E extends LivingEntity>
-
Field Summary
Modifier and TypeFieldDescriptionprivate Map<Activity,Set<MemoryModuleType<?>>>
private Map<Activity,Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryStatus>>>
private Activity
private long
(package private) static org.apache.logging.log4j.Logger
private Map<MemoryModuleType<?>,Optional<? extends ExpirableValue<?>>>
private Schedule
private static int
-
Constructor Summary
ConstructorDescriptionBrain(Collection<? extends MemoryModuleType<?>> p_21855_, Collection<? extends SensorType<? extends Sensor<? super E>>> p_21856_, com.google.common.collect.ImmutableList<Brain.MemoryValue<?>> p_21857_, Supplier<com.mojang.serialization.Codec<Brain<E>>> p_21858_)
-
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
activityRequirementsAreMet(Activity p_21970_)
void
addActivity(Activity p_21892_, int p_21893_, com.google.common.collect.ImmutableList<? extends Behavior<? super E>> p_21894_)
void
addActivity(Activity p_21901_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Behavior<? super E>>> p_21902_)
void
addActivityAndRemoveMemoriesWhenStopped(Activity p_21908_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Behavior<? super E>>> p_21909_, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryStatus>> p_21910_, Set<MemoryModuleType<?>> p_21911_)
void
addActivityAndRemoveMemoryWhenStopped(Activity p_21896_, int p_21897_, com.google.common.collect.ImmutableList<? extends Behavior<? super E>> p_21898_, MemoryModuleType<?> p_21899_)
void
addActivityWithConditions(Activity p_21904_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Behavior<? super E>>> p_21905_, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryStatus>> p_21906_)
boolean
checkMemory(MemoryModuleType<?> p_21877_, MemoryStatus p_21878_)
static <E extends LivingEntity>
com.mojang.serialization.Codec<Brain<E>>codec(Collection<? extends MemoryModuleType<?>> p_21947_, Collection<? extends SensorType<? extends Sensor<? super E>>> p_21948_)
(package private) com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Behavior<? super E>>>
createPriorityPairs(int p_21860_, com.google.common.collect.ImmutableList<? extends Behavior<? super E>> p_21861_)
private void
eraseMemoriesForOtherActivitesThan(Activity p_21967_)
<U> void
eraseMemory(MemoryModuleType<U> p_21937_)
private void
Deprecated.Map<MemoryModuleType<?>,Optional<? extends ExpirableValue<?>>>
Deprecated.<U> Optional<U>
getMemory(MemoryModuleType<U> p_21953_)
Deprecated.<U> long
getTimeUntilExpiry(MemoryModuleType<U> p_147342_)
boolean
hasMemoryValue(MemoryModuleType<?> p_21875_)
boolean
private boolean
isEmptyCollection(Object p_21919_)
<U> boolean
isMemoryValue(MemoryModuleType<U> p_21939_, U p_21940_)
(package private) Stream<Brain.MemoryValue<?>>
memories()
static <E extends LivingEntity>
Brain.Provider<E>provider(Collection<? extends MemoryModuleType<?>> p_21924_, Collection<? extends SensorType<? extends Sensor<? super E>>> p_21925_)
void
<T> com.mojang.serialization.DataResult<T>
serializeStart(com.mojang.serialization.DynamicOps<T> p_21915_)
private void
setActiveActivity(Activity p_21961_)
void
setActiveActivityIfPossible(Activity p_21890_)
void
setActiveActivityToFirstValid(List<Activity> p_21927_)
void
setCoreActivities(Set<Activity> p_21931_)
void
setDefaultActivity(Activity p_21945_)
<U> void
setMemory(MemoryModuleType<U> p_21887_, Optional<? extends U> p_21888_)
<U> void
setMemory(MemoryModuleType<U> p_21880_, U p_21881_)
(package private) <U> void
setMemoryInternal(MemoryModuleType<U> p_21942_, Optional<? extends ExpirableValue<?>> p_21943_)
<U> void
setMemoryWithExpiry(MemoryModuleType<U> p_21883_, U p_21884_, long p_21885_)
void
setSchedule(Schedule p_21913_)
private void
startEachNonRunningBehavior(ServerLevel p_21958_, E p_21959_)
void
stopAll(ServerLevel p_21934_, E p_21935_)
void
tick(ServerLevel p_21866_, E p_21867_)
private void
tickEachRunningBehavior(ServerLevel p_21964_, E p_21965_)
private void
tickSensors(ServerLevel p_21950_, E p_21951_)
void
updateActivityFromSchedule(long p_21863_, long p_21864_)
void
-
Field Details
-
LOGGER
static final org.apache.logging.log4j.Logger LOGGER -
codec
-
SCHEDULE_UPDATE_DELAY
private static final int SCHEDULE_UPDATE_DELAY- See Also:
- Constant Field Values
-
memories
-
sensors
private final Map<SensorType<? extends Sensor<? super E extends LivingEntity>>,Sensor<? super E extends LivingEntity>> sensors -
availableBehaviorsByPriority
-
schedule
-
activityRequirements
private final Map<Activity,Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryStatus>>> activityRequirements -
activityMemoriesToEraseWhenStopped
-
coreActivities
-
activeActivities
-
defaultActivity
-
lastScheduleUpdate
private long lastScheduleUpdate
-
-
Constructor Details
-
Brain
public Brain(Collection<? extends MemoryModuleType<?>> p_21855_, Collection<? extends SensorType<? extends Sensor<? super E>>> p_21856_, com.google.common.collect.ImmutableList<Brain.MemoryValue<?>> p_21857_, Supplier<com.mojang.serialization.Codec<Brain<E>>> p_21858_)
-
-
Method Details
-
provider
public static <E extends LivingEntity> Brain.Provider<E> provider(Collection<? extends MemoryModuleType<?>> p_21924_, Collection<? extends SensorType<? extends Sensor<? super E>>> p_21925_) -
codec
public static <E extends LivingEntity> com.mojang.serialization.Codec<Brain<E>> codec(Collection<? extends MemoryModuleType<?>> p_21947_, Collection<? extends SensorType<? extends Sensor<? super E>>> p_21948_) -
serializeStart
public <T> com.mojang.serialization.DataResult<T> serializeStart(com.mojang.serialization.DynamicOps<T> p_21915_) -
memories
Stream<Brain.MemoryValue<?>> memories() -
hasMemoryValue
-
eraseMemory
-
setMemory
-
setMemoryWithExpiry
-
setMemory
-
setMemoryInternal
<U> void setMemoryInternal(MemoryModuleType<U> p_21942_, Optional<? extends ExpirableValue<?>> p_21943_) -
getMemory
-
getTimeUntilExpiry
-
getMemories
Deprecated. -
isMemoryValue
-
checkMemory
-
getSchedule
-
setSchedule
-
setCoreActivities
-
getActiveActivities
Deprecated. -
getRunningBehaviors
Deprecated. -
useDefaultActivity
public void useDefaultActivity() -
getActiveNonCoreActivity
-
setActiveActivityIfPossible
-
setActiveActivity
-
eraseMemoriesForOtherActivitesThan
-
updateActivityFromSchedule
public void updateActivityFromSchedule(long p_21863_, long p_21864_) -
setActiveActivityToFirstValid
-
setDefaultActivity
-
addActivity
-
addActivityAndRemoveMemoryWhenStopped
public void addActivityAndRemoveMemoryWhenStopped(Activity p_21896_, int p_21897_, com.google.common.collect.ImmutableList<? extends Behavior<? super E>> p_21898_, MemoryModuleType<?> p_21899_) -
addActivity
-
addActivityWithConditions
public void addActivityWithConditions(Activity p_21904_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Behavior<? super E>>> p_21905_, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryStatus>> p_21906_) -
addActivityAndRemoveMemoriesWhenStopped
public void addActivityAndRemoveMemoriesWhenStopped(Activity p_21908_, com.google.common.collect.ImmutableList<? extends com.mojang.datafixers.util.Pair<Integer,? extends Behavior<? super E>>> p_21909_, Set<com.mojang.datafixers.util.Pair<MemoryModuleType<?>,MemoryStatus>> p_21910_, Set<MemoryModuleType<?>> p_21911_) -
removeAllBehaviors
public void removeAllBehaviors() -
isActive
-
copyWithoutBehaviors
-
tick
-
tickSensors
-
forgetOutdatedMemories
private void forgetOutdatedMemories() -
stopAll
-
startEachNonRunningBehavior
-
tickEachRunningBehavior
-
activityRequirementsAreMet
-
isEmptyCollection
-
createPriorityPairs
-