mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 03:22:23 +00:00
Fixed sync windup animation not being an ability property and getting overridden on gui init
This commit is contained in:
1 parent
b7fdda6905
commit
c39ce6b6d1
3 files changed
+53
-2
No files matched your search
@@ -20,6 +20,7 @@ import noppes.npcs.client.gui.util.IAbilityConfigCallback;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -57,6 +58,7 @@ public abstract class Ability implements IAbility {
|
||||
protected int cooldownTicks = 0; // Added to global cooldown after ability completes
|
||||
protected int windUpTicks = 20;
|
||||
protected int dazedTicks = 80; // Only used when interrupted during WINDUP (if interruptible)
|
||||
protected boolean syncWindupWithAnimation = true;
|
||||
|
||||
// Interruption
|
||||
protected boolean interruptible = true;
|
||||
@@ -972,7 +974,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public int getWindUpTicks() {
|
||||
return windUpTicks;
|
||||
return this.calculateWindupFromAnimation();
|
||||
}
|
||||
|
||||
public void setWindUpTicks(int windUpTicks) {
|
||||
@@ -987,6 +989,14 @@ public abstract class Ability implements IAbility {
|
||||
this.dazedTicks = Math.max(0, dazedTicks);
|
||||
}
|
||||
|
||||
public boolean isSyncWindupWithAnimation() {
|
||||
return syncWindupWithAnimation;
|
||||
}
|
||||
|
||||
public void setSyncWindupWithAnimation(boolean syncWindupWithAnimation) {
|
||||
this.syncWindupWithAnimation = syncWindupWithAnimation;
|
||||
}
|
||||
|
||||
public boolean isInterruptible() {
|
||||
return interruptible;
|
||||
}
|
||||
@@ -1234,6 +1244,43 @@ public abstract class Ability implements IAbility {
|
||||
effects.clear();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// SHIT FROM THE ASS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
private int calculateWindupFromAnimation() {
|
||||
if (!syncWindupWithAnimation) {
|
||||
return windUpTicks;
|
||||
}
|
||||
|
||||
if (AnimationController.Instance == null) {
|
||||
return this.windUpTicks;
|
||||
}
|
||||
|
||||
Animation animation = null;
|
||||
// Check for built-in animation (by name) first
|
||||
if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) {
|
||||
animation = (Animation) AnimationController.Instance.get(windUpAnimationName);
|
||||
}
|
||||
// Fall back to user animation (by ID)
|
||||
else if (windUpAnimationId >= 0) {
|
||||
animation = (Animation) AnimationController.Instance.get(windUpAnimationId);
|
||||
}
|
||||
|
||||
if (animation == null || animation.frames.isEmpty()) {
|
||||
return this.windUpTicks;
|
||||
}
|
||||
|
||||
// Calculate total duration by summing all frame durations
|
||||
int totalDuration = 0;
|
||||
for (Frame frame : animation.frames) {
|
||||
totalDuration += frame.getDuration();
|
||||
}
|
||||
|
||||
// Return total duration
|
||||
return totalDuration;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// IAbility API METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -33,4 +33,6 @@ public class Register<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO ADD ANIMATION REGISTER
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
protected int cooldownTicks;
|
||||
protected int windUpTicks;
|
||||
protected int dazedTicks;
|
||||
protected boolean syncWindupWithAnimation = true; // Sync windup ticks with animation duration
|
||||
protected boolean syncWindupWithAnimation; // Sync windup ticks with animation duration
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// CACHED VALUES - Target Tab
|
||||
@@ -120,6 +120,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
this.cooldownTicks = ability.getCooldownTicks();
|
||||
this.windUpTicks = ability.getWindUpTicks();
|
||||
this.dazedTicks = ability.getDazedTicks();
|
||||
this.syncWindupWithAnimation = ability.isSyncWindupWithAnimation();
|
||||
|
||||
// Target
|
||||
this.minRange = ability.getMinRange();
|
||||
@@ -923,6 +924,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
ability.setCooldownTicks(cooldownTicks);
|
||||
ability.setWindUpTicks(windUpTicks);
|
||||
ability.setDazedTicks(dazedTicks);
|
||||
ability.setSyncWindupWithAnimation(syncWindupWithAnimation);
|
||||
|
||||
// Target
|
||||
ability.setMinRange(minRange);
|
||||
|
||||
Reference in new issue
Block a user