Class Brain<E extends LivingEntity>


  • public class Brain<E extends LivingEntity>
    extends java.lang.Object
    • 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
      • availableBehaviorsByPriority

        private final java.util.Map<java.lang.Integer,​java.util.Map<Activity,​java.util.Set<Task<? super E extends LivingEntity>>>> availableBehaviorsByPriority
      • 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

      • 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_)
      • 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_)
      • 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_)
      • copyWithoutBehaviors

        public Brain<E> copyWithoutBehaviors()
      • 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_)
      • createPriorityPairs

        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_)