mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 19:09:22 +00:00
[ci skip] cleanup
This commit is contained in:
@@ -5,20 +5,22 @@ 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 ceff383d565267edd13a6d9006030b8e1f8053e3..71fb9a61e8d3ac7094d0630aebdc46dbe74dd0ae 100644
|
||||
index ceff383d565267edd13a6d9006030b8e1f8053e3..7dae9cc18cd6eede8f1b2196b55103428f35382e 100644
|
||||
--- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
|
||||
+++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
|
||||
@@ -88,8 +88,11 @@ public class AttributeInstance {
|
||||
@@ -88,8 +88,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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user