9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-24 01:19:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0148-Use-direct-iteration-on-Sensing.tick.patch
hayanesuru 124dc64a0d update async target finding and block finding (#296)
* reduce overhead on poll

* more async search entities

* async block search

* rename search entity config

* cleanup

* fix async search block too frequent

* remove alertOther Experimental anno

* Adjust the delay of RemoveBlockGoal to match vanilla behavior

* Optimize TemptGoal

* rollback interval change

* cleanup

* add async finding to DefendVillageTargetGoal

* rollback interval change for NearestHealableRaiderTargetGoal

* config searchPlayer

* fix DefendVillageTargetGoal condition doesn't check

* add async finding to BegGoal

* rollback interval change for FollowMobGoal

* cleanup

* add async finding to some follow goal

* add async finding to TemptGoal

* handle searchPlayer config

* fix TemptGoal
2025-04-24 13:18:53 +03:00

25 lines
1.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Sun, 23 Mar 2025 20:48:16 +0100
Subject: [PATCH] Use direct iteration on Sensing.tick
diff --git a/net/minecraft/world/entity/ai/sensing/Sensing.java b/net/minecraft/world/entity/ai/sensing/Sensing.java
index cc25f5838aec5ed9fca2fb8b0322fafad9397a46..002d3c0d8b1107a275020d5c582c37e9a5c536ee 100644
--- a/net/minecraft/world/entity/ai/sensing/Sensing.java
+++ b/net/minecraft/world/entity/ai/sensing/Sensing.java
@@ -39,7 +39,12 @@ public class Sensing {
} else {
var expiringNow = this.expiring[this.nextToExpireIndex];
- expiringNow.forEach(this.seen::remove);
+ // Leaf start - Use direct iteration on Sensing.tick
+ var iterator = expiringNow.iterator();
+ while (iterator.hasNext()) {
+ this.seen.remove(iterator.nextInt());
+ }
+ // Leaf end - Use direct iteration on Sensing.tick
expiringNow.clear();
this.currentCacheAddIndex++;