9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-03 22:26:19 +00:00

backport some fixes in async target finding

cb21caa1c2
58575d0adc
This commit is contained in:
hayanesuru
2025-06-29 13:47:48 +09:00
parent d81900dd61
commit e7c221e91d
71 changed files with 109 additions and 73 deletions

View File

@@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Sat, 22 Mar 2025 00:07:38 +0100
Subject: [PATCH] Optimize addOrUpdateTransientModifier
diff --git a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
index b502c4a0f3695cc5bee8954f937f64584df1584d..26d97742310c054eebbee7f4dc2f535d3ee4cd2e 100644
--- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
@@ -107,8 +107,13 @@ public class AttributeInstance {
}
public void addOrUpdateTransientModifier(AttributeModifier modifier) {
- AttributeModifier attributeModifier = this.modifierById.put(modifier.id(), modifier);
- if (modifier != attributeModifier) {
+ // Leaf start - Optimize addOrUpdateTransientModifier
+ // First check if we already have the same modifier instance to avoid unnecessary put operations
+ AttributeModifier existingModifier = this.modifierById.get(modifier.id());
+ // Only perform updates if the modifier is new or different
+ if (existingModifier != modifier) {
+ this.modifierById.put(modifier.id(), modifier);
+ // Leaf end - Optimize addOrUpdateTransientModifier
this.getModifiers(modifier.operation()).put(modifier.id(), modifier);
this.setDirty();
}