From c21a00706fdc4da71abf8aaf8209eb759f685a6d Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sun, 1 Sep 2024 16:36:42 +0200 Subject: [PATCH] Fix memory leak in heal-from-damage effects, Closes #1051 --- .../entityeffect/EnchantmentEntityEffectHealFromDamage.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/cyclops/evilcraft/enchantment/entityeffect/EnchantmentEntityEffectHealFromDamage.java b/src/main/java/org/cyclops/evilcraft/enchantment/entityeffect/EnchantmentEntityEffectHealFromDamage.java index 901b79c975..23395a818d 100644 --- a/src/main/java/org/cyclops/evilcraft/enchantment/entityeffect/EnchantmentEntityEffectHealFromDamage.java +++ b/src/main/java/org/cyclops/evilcraft/enchantment/entityeffect/EnchantmentEntityEffectHealFromDamage.java @@ -12,6 +12,7 @@ import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.entity.living.LivingDamageEvent; +import net.neoforged.neoforge.event.server.ServerStoppedEvent; import org.cyclops.evilcraft.Reference; /** @@ -36,6 +37,11 @@ public static void stealLife(LivingDamageEvent.Post event) { } } + @SubscribeEvent(priority = EventPriority.NORMAL) + public static void onServerStopped(ServerStoppedEvent event) { + lastDamageEvent = null; + } + @Override public void apply(ServerLevel level, int enchantmentLevel, EnchantedItemInUse enchantedItemInUse, Entity entity, Vec3 vec) { if (lastDamageEvent != null && lastDamageEvent.getSource().getEntity() == entity) {