mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 09:09:08 +00:00
Add Fail Safes to Cooldown and Locking
This commit is contained in:
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:
|
||||
|
||||
Reference in new issue
Block a user