mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
49 lines
2.5 KiB
Diff
49 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
|
Subject: [PATCH] Collect then startEachNonRunningBehavior in Brain
|
|
|
|
Removed since Leaf 1.21.4, replaced by Cache potential behaviors in Brain patch
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
|
index c561b749fb9b76ba9b1e9689089b743248c65d50..ea6c8e85ccff67b1c24109732f74f1e8199cad07 100644
|
|
--- a/net/minecraft/world/entity/ai/Brain.java
|
|
+++ b/net/minecraft/world/entity/ai/Brain.java
|
|
@@ -453,20 +453,29 @@ public class Brain<E extends LivingEntity> {
|
|
}
|
|
|
|
private void startEachNonRunningBehavior(ServerLevel level, E entity) {
|
|
- long gameTime = level.getGameTime();
|
|
+ // Leaf start - Collect then startEachNonRunningBehavior in Brain
|
|
+ final long gameTime = level.getGameTime();
|
|
+ List<BehaviorControl<? super E>> behaviorsToStart = new ObjectArrayList<>();
|
|
|
|
- for (Map<Activity, Set<BehaviorControl<? super E>>> map : this.availableBehaviorsByPriority.values()) {
|
|
- for (Entry<Activity, Set<BehaviorControl<? super E>>> entry : map.entrySet()) {
|
|
- Activity activity = entry.getKey();
|
|
- if (this.activeActivities.contains(activity)) {
|
|
- for (BehaviorControl<? super E> behaviorControl : entry.getValue()) {
|
|
+ for (Activity activeActivity : this.activeActivities) {
|
|
+ for (Map<Activity, Set<BehaviorControl<? super E>>> priorityMap : this.availableBehaviorsByPriority.values()) {
|
|
+ Set<BehaviorControl<? super E>> behaviors = priorityMap.get(activeActivity);
|
|
+
|
|
+ if (behaviors != null && !behaviors.isEmpty()) {
|
|
+ for (BehaviorControl<? super E> behaviorControl : behaviors) {
|
|
if (behaviorControl.getStatus() == Behavior.Status.STOPPED) {
|
|
- behaviorControl.tryStart(level, entity, gameTime);
|
|
+ behaviorsToStart.add(behaviorControl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
+ if (!behaviorsToStart.isEmpty()) {
|
|
+ for (BehaviorControl<? super E> behaviorControl : behaviorsToStart) {
|
|
+ behaviorControl.tryStart(level, entity, gameTime);
|
|
+ }
|
|
+ }
|
|
+ // Leaf end - Collect then startEachNonRunningBehavior in Brain
|
|
}
|
|
|
|
private void tickEachRunningBehavior(ServerLevel level, E entity) {
|