WIP Animations Register

This commit is contained in:
Vidal committed 2026-02-01 20:09:12 -03:00
1 parent c39ce6b6d1
commit c168702970
4 files changed
+43 -14

No files matched your search

@@ -120,12 +120,9 @@ public class AnimationController implements IAnimationHandler {
}
}
/**
* Load a single built-in animation by name from assets folder.
*/
private void loadBuiltInAnimation(String animName) throws Exception {
String resourcePath = BUILTIN_ANIMATIONS_PATH + "/" + animName + ".json";
try (InputStream stream = CustomNpcs.class.getResourceAsStream(resourcePath)) {
public void loadBuiltInAnimation(Class<?> modClass, String path, String animName) throws Exception {
String resourcePath = path + "/" + animName + ".json";
try (InputStream stream = modClass.getResourceAsStream(resourcePath)) {
if (stream == null) {
return;
}
@@ -150,6 +147,13 @@ public class AnimationController implements IAnimationHandler {
}
}
/**
* Load a single built-in animation by name from assets folder.
*/
private void loadBuiltInAnimation(String animName) throws Exception {
loadBuiltInAnimation(CustomNpcs.class, BUILTIN_ANIMATIONS_PATH, animName);
}
private void loadAnimations() {
animations.clear();
@@ -314,6 +318,10 @@ public class AnimationController implements IAnimationHandler {
}
public IAnimation get(String name) {
return get(name, false);
}
public IAnimation get(String name, boolean builtIn) {
// Check user/custom animations first (allows overriding built-in)
for (Map.Entry<Integer, Animation> entry : animations.entrySet()) {
if (entry.getValue().name.equalsIgnoreCase(name)) {
@@ -321,10 +329,13 @@ public class AnimationController implements IAnimationHandler {
}
}
// Then check built-in animations
BuiltInAnimation builtIn = builtInAnimations.get(name.toLowerCase());
if (builtIn != null) {
return builtIn;
if (builtIn) {
BuiltInAnimation builtInAnim = builtInAnimations.get(name.toLowerCase());
if (builtInAnim != null) {
return builtInAnim;
}
}
return null;
}