package com.tiedup.remake.client.animation;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* Client-side animation state tracking + world-unload cleanup facade.
*
*
Holds {@link #lastTiedState} (the per-player edge-detector used by
* {@link com.tiedup.remake.client.animation.tick.AnimationTickHandler} to
* spot the "just untied" transition) and chains cleanup via
* {@link #clearAll()} across every animation-related cache on world unload.
*/
@OnlyIn(Dist.CLIENT)
public final class AnimationStateRegistry {
/** Track last tied state per player (edge-detect on untie transition). */
static final Map lastTiedState = new ConcurrentHashMap<>();
private AnimationStateRegistry() {}
public static Map getLastTiedState() {
return lastTiedState;
}
/**
* Clear all animation-related state in one call.
* Called on world unload to prevent memory leaks and stale data.
*/
public static void clearAll() {
// Animation state tracking
lastTiedState.clear();
// Animation managers
BondageAnimationManager.clearAll();
PendingAnimationManager.clearAll();
// V2 animation context system (clearAll chains to ContextAnimationFactory.clearCache)
com.tiedup.remake.client.gltf.GltfAnimationApplier.clearAll();
// Render state
com.tiedup.remake.client.animation.render.DogPoseRenderHandler.clearState();
com.tiedup.remake.client.animation.render.PetBedRenderHandler.clearAll();
com.tiedup.remake.client.animation.render.HeldItemHideHandler.clearAll();
com.tiedup.remake.client.animation.render.PlayerArmHideEventHandler.clearAll();
// NPC animation state
com.tiedup.remake.client.animation.tick.NpcAnimationTickHandler.clearAll();
// MCA animation cache
com.tiedup.remake.client.animation.tick.MCAAnimationTickCache.clear();
}
}