9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-21 16:09:19 +00:00
Files
Leaf/patches/server/0084-Replace-Entity-active-effects-map-with-optimized-col.patch

40 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Tue, 17 Sep 2024 02:35:13 -0400
Subject: [PATCH] Replace Entity active effects map with optimized collection
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 731105edcdef57b5e497fd6c0a556c6180dd6e3f..bc3075fcba4e3c5e9e927928bbc432c0e4d1bc96 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -199,7 +199,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
public static final String ATTRIBUTES_FIELD = "attributes";
private final AttributeMap attributes;
public CombatTracker combatTracker = new CombatTracker(this);
- public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = Maps.newHashMap();
+ public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(0); // Leaf - Replace Entity active effects map with optimized collection
private final NonNullList<ItemStack> lastHandItemStacks;
private final NonNullList<ItemStack> lastArmorItemStacks;
private ItemStack lastBodyItemStack;
@@ -1011,8 +1011,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
private void updateSynchronizedMobEffectParticles() {
// Leaf start - Remove stream in entity visible effects filter
List<ParticleOptions> list = new ArrayList<>();
+ final Collection<MobEffectInstance> effectsValues = this.activeEffects.values(); // Leaf - Replace Entity active effects map with optimized collection
- for (MobEffectInstance effect : this.activeEffects.values()) {
+ for (MobEffectInstance effect : effectsValues) { // Leaf - Replace Entity active effects map with optimized collection
if (effect.isVisible()) {
list.add(effect.getParticleOptions());
}
@@ -1020,7 +1021,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Leaf end - Remove stream in entity visible effects filter
this.entityData.set(LivingEntity.DATA_EFFECT_PARTICLES, list);
- this.entityData.set(LivingEntity.DATA_EFFECT_AMBIENCE_ID, LivingEntity.areAllEffectsAmbient(this.activeEffects.values()));
+ this.entityData.set(LivingEntity.DATA_EFFECT_AMBIENCE_ID, LivingEntity.areAllEffectsAmbient(effectsValues)); // Leaf - Replace Entity active effects map with optimized collection
}
private void updateGlowingStatus() {