Add Fail Safes to Cooldown and Locking

This commit is contained in:
Kam committed 2026-02-24 00:12:18 -05:00
1 parent abc34b3f6f
commit 2f170363de
4 files changed
+93 -4

No files matched your search

@@ -35,6 +35,13 @@ import java.util.Set;
*/
public abstract class AbstractDataAbilities {
/**
* Safety timeout (ticks) for abilities stuck in ACTIVE phase.
* If an ability stays in ACTIVE for longer than this without calling signalCompletion(),
* it is force-completed to prevent permanent stuck state. 30 seconds at 20 TPS.
*/
protected static final int MAX_ACTIVE_PHASE_TICKS = 600;
// ═══════════════════════════════════════════════════════════════════
// SHARED RUNTIME STATE (not saved to NBT)
// ═══════════════════════════════════════════════════════════════════
@@ -864,6 +871,16 @@ public abstract class AbstractDataAbilities {
if (positionLocked) releaseLockedPosition();
onBurstDelayReleaseLocks();
}
// Safety timeout: force-complete if stuck in ACTIVE too long.
// Individual ability types should have their own timeouts well below this;
// this is a last-resort failsafe to prevent permanent stuck state.
if (currentAbility != null && currentAbility.getPhase() == AbilityPhase.ACTIVE
&& currentAbility.getCurrentTick() > MAX_ACTIVE_PHASE_TICKS) {
currentAbility.cancel();
handleAbilityCompletion(target);
return;
}
break;
case BURST_DELAY: