mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 05:45:03 +00:00
Fix Windup Ticks 0 not starting Abilities
This commit is contained in:
1 parent
bc4f82e55f
commit
769109d046
4 files changed
+96
-30
No files matched your search
@@ -662,13 +662,19 @@ public abstract class Ability implements IAbility {
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Start executing this ability
|
||||
* Start executing this ability.
|
||||
* If windUpTicks is 0, skips WINDUP and goes directly to ACTIVE.
|
||||
*/
|
||||
public void start(EntityLivingBase target) {
|
||||
this.phase = AbilityPhase.WINDUP;
|
||||
this.currentTick = 0;
|
||||
this.currentTarget = target;
|
||||
this.executionStartTime = System.currentTimeMillis();
|
||||
|
||||
if (windUpTicks <= 0) {
|
||||
this.phase = AbilityPhase.ACTIVE;
|
||||
} else {
|
||||
this.phase = AbilityPhase.WINDUP;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -385,18 +385,49 @@ public class DataAbilities {
|
||||
lastTarget = target;
|
||||
ability.start(target);
|
||||
|
||||
// Spawn telegraph and send to clients
|
||||
spawnTelegraph(ability, target);
|
||||
|
||||
// Play wind up sound if configured
|
||||
playAbilitySound(ability.getWindUpSound());
|
||||
|
||||
// Play wind up animation if configured
|
||||
playAbilityAnimation(ability.getWindUpAnimation());
|
||||
if (ability.getPhase() == AbilityPhase.ACTIVE) {
|
||||
// Windup was 0 — skip telegraph/windup and go straight to active
|
||||
executeImmediate(ability, target);
|
||||
} else {
|
||||
// Normal windup flow
|
||||
spawnTelegraph(ability, target);
|
||||
playAbilitySound(ability.getWindUpSound());
|
||||
playAbilityAnimation(ability.getWindUpAnimation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an ability immediately (no windup).
|
||||
* Called when windUpTicks is 0.
|
||||
*/
|
||||
private void executeImmediate(Ability ability, EntityLivingBase target) {
|
||||
// Lock rotation if movement is locked during ACTIVE phase
|
||||
if (ability.isMovementLockedDuringActive()) {
|
||||
captureLockedRotation();
|
||||
}
|
||||
|
||||
// Play active sound and animation
|
||||
playAbilitySound(ability.getActiveSound());
|
||||
playAbilityAnimation(ability.getActiveAnimation());
|
||||
|
||||
// Fire execute event (cancelable)
|
||||
AbilityEvent.ExecuteEvent executeEvent = new AbilityEvent.ExecuteEvent(
|
||||
npc.wrappedNPC, ability, target);
|
||||
if (NpcAPI.EVENT_BUS.post(executeEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Call onExecute
|
||||
ability.onExecute(npc, target, npc.worldObj);
|
||||
|
||||
// Check if ability completed during onExecute
|
||||
if (ability.getPhase() == AbilityPhase.IDLE) {
|
||||
handleAbilityCompletion(target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Play a sound at the NPC's location.
|
||||
*/
|
||||
|
||||
@@ -81,7 +81,6 @@ public class AbilityPreviewExecutor {
|
||||
|
||||
this.previewAbility = ability;
|
||||
this.previewNpc = npc;
|
||||
this.phase = AbilityPhase.WINDUP;
|
||||
this.currentTick = 0;
|
||||
this.playing = true;
|
||||
this.paused = false;
|
||||
@@ -103,21 +102,30 @@ public class AbilityPreviewExecutor {
|
||||
parentGui.startTrackingMovement();
|
||||
}
|
||||
|
||||
// Create telegraph for preview
|
||||
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
|
||||
if (ability.getWindUpTicks() <= 0) {
|
||||
// No windup — go straight to active
|
||||
this.phase = AbilityPhase.ACTIVE;
|
||||
transitionToActive();
|
||||
} else {
|
||||
// Normal windup flow
|
||||
this.phase = AbilityPhase.WINDUP;
|
||||
|
||||
// Start windup animation
|
||||
Animation windUpAnim = ability.getWindUpAnimation();
|
||||
if (windUpAnim != null) {
|
||||
AnimationData data = npc.display.animationData;
|
||||
data.setEnabled(true);
|
||||
data.setAnimation(windUpAnim);
|
||||
data.animation.paused = false;
|
||||
}
|
||||
// Create telegraph for preview
|
||||
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
|
||||
|
||||
// Spawn preview entity on first tick if ability spawns during windup
|
||||
if (ability.spawnPreviewDuringWindup()) {
|
||||
spawnPreviewEntity();
|
||||
// Start windup animation
|
||||
Animation windUpAnim = ability.getWindUpAnimation();
|
||||
if (windUpAnim != null) {
|
||||
AnimationData data = npc.display.animationData;
|
||||
data.setEnabled(true);
|
||||
data.setAnimation(windUpAnim);
|
||||
data.animation.paused = false;
|
||||
}
|
||||
|
||||
// Spawn preview entity on first tick if ability spawns during windup
|
||||
if (ability.spawnPreviewDuringWindup()) {
|
||||
spawnPreviewEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,16 +229,37 @@ public class PlayerAbilityData implements IPlayerAbilityData {
|
||||
currentTarget = null; // Players don't have auto-targets
|
||||
ability.start(null);
|
||||
|
||||
// Spawn telegraph
|
||||
spawnTelegraph(ability, player, null);
|
||||
|
||||
// Play wind up sound and animation
|
||||
playAbilitySound(player, ability.getWindUpSound());
|
||||
playAbilityAnimation(ability.getWindUpAnimation());
|
||||
if (ability.getPhase() == AbilityPhase.ACTIVE) {
|
||||
// Windup was 0 — skip telegraph/windup and go straight to active
|
||||
executeImmediate(ability, player);
|
||||
} else {
|
||||
// Normal windup flow
|
||||
spawnTelegraph(ability, player, null);
|
||||
playAbilitySound(player, ability.getWindUpSound());
|
||||
playAbilityAnimation(ability.getWindUpAnimation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute an ability immediately (no windup).
|
||||
* Called when windUpTicks is 0.
|
||||
*/
|
||||
private void executeImmediate(Ability ability, EntityPlayer player) {
|
||||
// Play active sound and animation
|
||||
playAbilitySound(player, ability.getActiveSound());
|
||||
playAbilityAnimation(ability.getActiveAnimation());
|
||||
|
||||
// Call onExecute
|
||||
ability.onExecute(player, currentTarget, player.worldObj);
|
||||
|
||||
// Check if ability completed during onExecute
|
||||
if (ability.getPhase() == AbilityPhase.IDLE) {
|
||||
handleAbilityCompletion(player);
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// CLIENT SYNC
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in new issue
Block a user