9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-30 20:39:21 +00:00

Couple fixes and improvements (#287)

* a lot of cleanup and new chunk changes

* perf: Head Node Hit Optimization

* part 1: reworked-reworked ChunkHolderManager

* part 2: speeeeeeeeeeeeeeeeeeeeeeeeeeed

* Optimise MobEffectUtil#getDigSpeedAmplification

* optimize chunk unloads and cleanup a bit

* fix 🐝

* rewritten async target finding

* extend the custom map usage

---------

Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
This commit is contained in:
Taiyou
2025-04-21 22:49:33 +02:00
committed by GitHub
parent e82999dd18
commit 83e9043a45
37 changed files with 2884 additions and 310 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 ceff383d565267edd13a6d9006030b8e1f8053e3..7dae9cc18cd6eede8f1b2196b55103428f35382e 100644
--- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java
@@ -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();
}