This is generated by calude As it's only change the display, no tests and review are required
35 lines
3.0 KiB
Diff
35 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <mrhua269@gmail.com>
|
|
Date: Sat, 18 Apr 2026 12:27:21 +0800
|
|
Subject: [PATCH] Leaf: Replace brain maps with optimized collection
|
|
|
|
Co-authored by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
As part of: Leaf (https://github.com/Winds-Studio/Leaf/blob/7f3e240bbe0970683c40279a7a65f0fde47503b6/leaf-server/minecraft-patches/features/0070-Replace-brain-maps-with-optimized-collection.patch)
|
|
Licensed under: MIT (https://github.com/Winds-Studio/Leaf/blob/7f3e240bbe0970683c40279a7a65f0fde47503b6/licenses/MIT.txt)
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
|
index 977a31f995799cf44fa59cc1db73571edbcf36ff..ba28111819aacc30b410763adffc4d4dd2b545d4 100644
|
|
--- a/net/minecraft/world/entity/ai/Brain.java
|
|
+++ b/net/minecraft/world/entity/ai/Brain.java
|
|
@@ -37,14 +37,14 @@ import org.jspecify.annotations.Nullable;
|
|
|
|
public class Brain<E extends LivingEntity> {
|
|
private static final int SCHEDULE_UPDATE_DELAY = 20;
|
|
- private final Map<MemoryModuleType<?>, MemorySlot<?>> memories = Maps.newHashMap();
|
|
- private final Map<SensorType<? extends Sensor<? super E>>, Sensor<? super E>> sensors = Maps.newLinkedHashMap();
|
|
+ private final Map<MemoryModuleType<?>, MemorySlot<?>> memories = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // Leaf - Replace brain maps with optimized collection
|
|
+ private final Map<SensorType<? extends Sensor<? super E>>, Sensor<? super E>> sensors = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); // Leaf - Replace brain maps with optimized collection
|
|
private final Map<Integer, Map<Activity, Set<BehaviorControl<? super E>>>> availableBehaviorsByPriority = Maps.newTreeMap();
|
|
private @Nullable EnvironmentAttribute<Activity> schedule;
|
|
- private final Map<Activity, Set<Pair<MemoryModuleType<?>, MemoryStatus>>> activityRequirements = Maps.newHashMap();
|
|
- private final Map<Activity, Set<MemoryModuleType<?>>> activityMemoriesToEraseWhenStopped = Maps.newHashMap();
|
|
- private Set<Activity> coreActivities = Sets.newHashSet();
|
|
- private final Set<Activity> activeActivities = Sets.newHashSet();
|
|
+ private final Map<Activity, Set<Pair<MemoryModuleType<?>, MemoryStatus>>> activityRequirements = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // Leaf - Replace brain maps with optimized collection
|
|
+ private final Map<Activity, Set<MemoryModuleType<?>>> activityMemoriesToEraseWhenStopped = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // Leaf - Replace brain maps with optimized collection
|
|
+ private Set<Activity> coreActivities = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(); // Leaf - Replace brain maps with optimized collection
|
|
+ private final Set<Activity> activeActivities = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(); // Leaf - Replace brain maps with optimized collection
|
|
private Activity defaultActivity = Activity.IDLE;
|
|
private long lastScheduleUpdate = -9999L;
|
|
|