package com.tiedup.remake.client.events; import com.mojang.logging.LogUtils; import com.tiedup.remake.client.animation.BondageAnimationManager; import com.tiedup.remake.client.animation.PendingAnimationManager; import com.tiedup.remake.core.TiedUpMod; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.EntityLeaveLevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import org.slf4j.Logger; /** * Automatic cleanup handler for entity-related resources. * *
This handler automatically cleans up animation layers and pending animations * when entities leave the world, preventing memory leaks from stale cache entries. * *
Phase: Performance & Memory Management * *
Previously, cleanup had to be called manually via {@link BondageAnimationManager#cleanup(java.util.UUID)}, * which was error-prone and could lead to memory leaks if forgotten. * This handler ensures cleanup happens automatically on entity removal. */ @Mod.EventBusSubscriber( modid = TiedUpMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT ) public class EntityCleanupHandler { private static final Logger LOGGER = LogUtils.getLogger(); /** * Automatically clean up animation resources when an entity leaves the world. * *
This event fires when: *
Cleanup includes: *