Made animation fetching methods return Animation instead of IDs

This commit is contained in:
Vidal committed 2026-01-27 04:36:12 -03:00
1 parent 39b53b0be7
commit 93486d306b
3 files changed
+28 -17

No files matched your search

@@ -17,6 +17,8 @@ import noppes.npcs.api.INbt;
import noppes.npcs.api.ability.IAbility;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.AbilityEvent;
@@ -927,16 +929,20 @@ public abstract class Ability implements IAbility {
this.activeSound = activeSound;
}
public int getWindUpAnimationId() {
return windUpAnimationId;
public Animation getWindUpAnimation() {
if (AnimationController.Instance == null) return null;
return (Animation) AnimationController.Instance.get(windUpAnimationId);
}
public void setWindUpAnimationId(int windUpAnimationId) {
this.windUpAnimationId = windUpAnimationId;
}
public int getActiveAnimationId() {
return activeAnimationId;
public Animation getActiveAnimation() {
if (AnimationController.Instance == null) return null;
return (Animation) AnimationController.Instance.get(activeAnimationId);
}
public void setActiveAnimationId(int activeAnimationId) {
+16 -11
View File
@@ -154,7 +154,7 @@ public class DataAbilities {
// Play active sound and animation
playAbilitySound(currentAbility.getActiveSound());
playAbilityAnimation(currentAbility.getActiveAnimationId());
playAbilityAnimation(currentAbility.getActiveAnimation());
// Fire execute event (cancelable)
AbilityEvent.ExecuteEvent executeEvent = new AbilityEvent.ExecuteEvent(
@@ -359,7 +359,7 @@ public class DataAbilities {
playAbilitySound(ability.getWindUpSound());
// Play wind up animation if configured
playAbilityAnimation(ability.getWindUpAnimationId());
playAbilityAnimation(ability.getWindUpAnimation());
return true;
}
@@ -377,18 +377,23 @@ public class DataAbilities {
* Play an animation on the NPC by ID.
* Public so abilities can trigger animations directly if needed.
*
* @param animationId The global animation ID to play, or -1 for none
* @param animation The animation to play, or null if none
*/
public void playAbilityAnimation(int animationId) {
if (animationId < 0) return;
public void playAbilityAnimation(Animation animation) {
if (animation == null || animation.id < 0) return;
if (AnimationController.Instance == null) return;
Animation animation = AnimationController.Instance.animations.get(animationId);
if (animation != null) {
npc.display.animationData.setEnabled(true);
npc.display.animationData.setAnimation(animation);
npc.display.animationData.updateClient();
}
npc.display.animationData.setEnabled(true);
npc.display.animationData.setAnimation(animation);
npc.display.animationData.updateClient();
}
public void playAbilityAnimation(int animation) {
if (animation < 0) return;
if (AnimationController.Instance == null) return;
if (AnimationController.Instance.get(animation) == null) return;
playAbilityAnimation((Animation) AnimationController.Instance.get(animation));
}
/**
@@ -127,8 +127,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Effects
this.windUpSound = ability.getWindUpSound();
this.activeSound = ability.getActiveSound();
this.windUpAnimationId = ability.getWindUpAnimationId();
this.activeAnimationId = ability.getActiveAnimationId();
this.windUpAnimationId = ability.getWindUpAnimation() != null ? ability.getWindUpAnimation().getID() : -1;
this.activeAnimationId = ability.getActiveAnimation() != null ? ability.getActiveAnimation().getID() : -1;
// Telegraph
this.showTelegraph = ability.isShowTelegraph();