mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 09:59:42 +00:00
Fix Cooldown Logic
This commit is contained in:
1 parent
747aae8337
commit
4330405f96
2 files changed
+36
-10
No files matched your search
@@ -166,8 +166,20 @@ public class DataAbilities {
|
||||
|
||||
// Call onExecute
|
||||
currentAbility.onExecute(npc, target, npc.worldObj);
|
||||
|
||||
// Check if ability completed during onExecute (signalCompletion was called)
|
||||
if (currentAbility.getPhase() == AbilityPhase.IDLE) {
|
||||
handleAbilityCompletion(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
currentAbility.onActiveTick(npc, target, npc.worldObj, currentAbility.getCurrentTick());
|
||||
|
||||
// Check if ability completed during onActiveTick (signalCompletion was called)
|
||||
if (currentAbility.getPhase() == AbilityPhase.IDLE) {
|
||||
handleAbilityCompletion(target);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case DAZED:
|
||||
@@ -175,17 +187,31 @@ public class DataAbilities {
|
||||
break;
|
||||
|
||||
case IDLE:
|
||||
// Ability completed
|
||||
currentAbility.onComplete(npc, target);
|
||||
|
||||
// Fire complete event
|
||||
AbilityEvent.CompleteEvent completeEvent = new AbilityEvent.CompleteEvent(
|
||||
npc.wrappedNPC, currentAbility, target);
|
||||
NpcAPI.EVENT_BUS.post(completeEvent);
|
||||
|
||||
onAbilityComplete();
|
||||
// Ability completed (reached via tick() phase transition from DAZED)
|
||||
handleAbilityCompletion(target);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle ability completion - called when ability phase becomes IDLE.
|
||||
* This can happen from:
|
||||
* - signalCompletion() called in onExecute() or onActiveTick()
|
||||
* - tick() transitioning from DAZED to IDLE
|
||||
*/
|
||||
private void handleAbilityCompletion(EntityLivingBase target) {
|
||||
if (currentAbility == null) return;
|
||||
|
||||
// Call onComplete callback
|
||||
currentAbility.onComplete(npc, target);
|
||||
|
||||
// Fire complete event
|
||||
AbilityEvent.CompleteEvent completeEvent = new AbilityEvent.CompleteEvent(
|
||||
npc.wrappedNPC, currentAbility, target);
|
||||
NpcAPI.EVENT_BUS.post(completeEvent);
|
||||
|
||||
// Clean up and roll cooldown
|
||||
onAbilityComplete();
|
||||
|
||||
// Clear AI pathfinding if ability is controlling movement
|
||||
// But DON'T zero motion - let the ability set it if needed
|
||||
|
||||
Reference in new issue
Block a user