mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
* optimize tracker * optimize scaledRange * cleanup * fix loop * fix loop * optimize AttributeMap * optimize TrackedEntity#seenBy * revert packDirty * cleanup
27 lines
1.4 KiB
Diff
27 lines
1.4 KiB
Diff
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 8013594bb4844e7a8abf28123958e7f632d39341..7505485c8965e5492a9d68288596178cfe0971ee 100644
|
|
--- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
|
|
+++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
|
|
@@ -85,8 +85,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();
|
|
}
|