Skip to content

Commit

Permalink
Fix memory leak in heal-from-damage effects, Closes #1051
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Sep 1, 2024
1 parent fe0ef57 commit c21a007
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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) {
Expand Down

0 comments on commit c21a007

Please sign in to comment.