mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-14 04:59:57 +00:00
Fix Animation Lookup
This commit is contained in:
1 parent
3bbde1f748
commit
3bd25c689b
2 files changed
+42
-26
No files matched your search
@@ -1378,9 +1378,10 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
nbt.setInteger("windUpAnimationId", windUpAnimationId);
|
||||
nbt.setInteger("activeAnimationId", activeAnimationId);
|
||||
nbt.setInteger("dazedAnimationId", dazedAnimationId);
|
||||
nbt.setString("windUpAnimationName", windUpAnimationName);
|
||||
nbt.setString("activeAnimationName", activeAnimationName);
|
||||
nbt.setString("dazedAnimationName", dazedAnimationName);
|
||||
// Resolve current animation names from controller before writing
|
||||
nbt.setString("windUpAnimationName", resolveAnimationName(windUpAnimationId, windUpAnimationName));
|
||||
nbt.setString("activeAnimationName", resolveAnimationName(activeAnimationId, activeAnimationName));
|
||||
nbt.setString("dazedAnimationName", resolveAnimationName(dazedAnimationId, dazedAnimationName));
|
||||
nbt.setBoolean("showTelegraph", showTelegraph);
|
||||
nbt.setString("telegraphType", telegraphType.name());
|
||||
nbt.setFloat("telegraphHeightOffset", telegraphHeightOffset);
|
||||
@@ -1994,17 +1995,32 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
this.activeSound = activeSound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the current animation name for a custom animation ID.
|
||||
* If the ID refers to a custom animation, looks up the current name from the controller.
|
||||
* For built-in animations (id == -1), returns the stored name as-is.
|
||||
*/
|
||||
protected String resolveAnimationName(int animId, String storedName) {
|
||||
if (animId >= 0 && AnimationController.Instance != null) {
|
||||
Animation anim = (Animation) AnimationController.Instance.get(animId);
|
||||
if (anim != null && anim.name != null && !anim.name.isEmpty()) {
|
||||
return anim.name;
|
||||
}
|
||||
}
|
||||
return storedName;
|
||||
}
|
||||
|
||||
public Animation getWindUpAnimation() {
|
||||
if (AnimationController.Instance == null) return null;
|
||||
|
||||
// Built-in animation by name takes priority
|
||||
if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) {
|
||||
return (Animation) AnimationController.Instance.get(windUpAnimationName, true);
|
||||
}
|
||||
// Fall back to user animation by ID
|
||||
// Custom animation by ID (most reliable, survives renames)
|
||||
if (windUpAnimationId >= 0) {
|
||||
return (Animation) AnimationController.Instance.get(windUpAnimationId);
|
||||
}
|
||||
// Built-in animation by name
|
||||
if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) {
|
||||
return (Animation) AnimationController.Instance.get(windUpAnimationName, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2027,14 +2043,14 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
public Animation getActiveAnimation() {
|
||||
if (AnimationController.Instance == null) return null;
|
||||
|
||||
// Built-in animation by name takes priority
|
||||
if (activeAnimationName != null && !activeAnimationName.isEmpty()) {
|
||||
return (Animation) AnimationController.Instance.get(activeAnimationName, true);
|
||||
}
|
||||
// Fall back to user animation by ID
|
||||
// Custom animation by ID (most reliable, survives renames)
|
||||
if (activeAnimationId >= 0) {
|
||||
return (Animation) AnimationController.Instance.get(activeAnimationId);
|
||||
}
|
||||
// Built-in animation by name
|
||||
if (activeAnimationName != null && !activeAnimationName.isEmpty()) {
|
||||
return (Animation) AnimationController.Instance.get(activeAnimationName, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2057,14 +2073,14 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
public Animation getDazedAnimation() {
|
||||
if (AnimationController.Instance == null) return null;
|
||||
|
||||
// Built-in animation by name takes priority
|
||||
if (dazedAnimationName != null && !dazedAnimationName.isEmpty()) {
|
||||
return (Animation) AnimationController.Instance.get(dazedAnimationName, true);
|
||||
}
|
||||
// Fall back to user animation by ID
|
||||
// Custom animation by ID (most reliable, survives renames)
|
||||
if (dazedAnimationId >= 0) {
|
||||
return (Animation) AnimationController.Instance.get(dazedAnimationId);
|
||||
}
|
||||
// Built-in animation by name
|
||||
if (dazedAnimationName != null && !dazedAnimationName.isEmpty()) {
|
||||
return (Animation) AnimationController.Instance.get(dazedAnimationName, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2314,14 +2330,14 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
}
|
||||
|
||||
Animation animation = null;
|
||||
// Check for built-in animation (by name) first
|
||||
if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) {
|
||||
animation = (Animation) AnimationController.Instance.get(windUpAnimationName, true);
|
||||
}
|
||||
// Fall back to user animation (by ID)
|
||||
else if (windUpAnimationId >= 0) {
|
||||
// Custom animation by ID (most reliable, survives renames)
|
||||
if (windUpAnimationId >= 0) {
|
||||
animation = (Animation) AnimationController.Instance.get(windUpAnimationId);
|
||||
}
|
||||
// Built-in animation by name
|
||||
else if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) {
|
||||
animation = (Animation) AnimationController.Instance.get(windUpAnimationName, true);
|
||||
}
|
||||
|
||||
if (animation == null || animation.frames.isEmpty()) {
|
||||
return this.windUpTicks;
|
||||
|
||||
@@ -191,7 +191,7 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
private IAnimation getCounterAnimation() {
|
||||
if (AnimationController.Instance == null) return null;
|
||||
|
||||
if (counterAnimationId > 0) {
|
||||
if (counterAnimationId >= 0) {
|
||||
return AnimationController.Instance.get(counterAnimationId);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
nbt.setFloat("counterValue", counterValue);
|
||||
nbt.setString("counterSound", counterSound);
|
||||
nbt.setInteger("counterAnimationId", counterAnimationId);
|
||||
nbt.setString("counterAnimationName", counterAnimationName);
|
||||
nbt.setString("counterAnimationName", resolveAnimationName(counterAnimationId, counterAnimationName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user