diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java index 9f3caa3..f3db173 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/AnimationController.java @@ -992,6 +992,20 @@ public AdvancedPlayerAnimBone registerPlayerAnimBone(String name) { return registerPlayerAnimBone(new AdvancedPlayerAnimBone(name)); } + @Override + public boolean modifiesPart(String name) { + return this.activeBones.containsKey(name); + } + + @Override + public boolean bendsPart(String name) { + if (modifiesPart(name) && this.bones.containsKey(name)) { + AdvancedPlayerAnimBone bone = this.bones.get(name); + return bone.bendEnabled && bone.bend != 0; + } + return false; + } + /** * Adds the given bone to the bones list for this controller *

diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java index a8d8030..30253f3 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationContainer.java @@ -89,6 +89,16 @@ public void setupAnim(AnimationData state) { return anim != null ? anim.getFirstPersonConfiguration() : IAnimation.super.getFirstPersonConfiguration(); } + @Override + public boolean modifiesPart(String name) { + return anim != null && anim.modifiesPart(name); + } + + @Override + public boolean bendsPart(String name) { + return anim != null && anim.bendsPart(name); + } + @Override public String toString() { return "AnimationContainer{" + diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java index 24e53a1..091cf47 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationSnapshot.java @@ -20,6 +20,20 @@ public PlayerAnimBone get3DTransform(@NotNull PlayerAnimBone bone) { return bone; } + @Override + public boolean modifiesPart(String name) { + return snapshots.containsKey(name); + } + + @Override + public boolean bendsPart(String name) { + if (modifiesPart(name)) { + AdvancedBoneSnapshot snapshot = snapshots.get(name); + return snapshot.bendEnabled && snapshot.getBend() != 0; + } + return false; + } + @Override public @NotNull String toString() { return "AnimationSnapshot{" + diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java index 65466bb..5dd8df3 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/AnimationStack.java @@ -114,6 +114,22 @@ public boolean removeLayer(int layerLevel) { return IAnimation.super.getFirstPersonConfiguration(); } + @Override + public boolean modifiesPart(String name) { + for (int i = layers.size(); i > 0;) { + if (layers.get(--i).right().modifiesPart(name)) return true; + } + return false; + } + + @Override + public boolean bendsPart(String name) { + for (int i = layers.size(); i > 0;) { + if (layers.get(--i).right().bendsPart(name)) return true; + } + return false; + } + public int getPriority() { int priority = 0; for (int i=layers.size()-1; i>=0; i--) { diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java index 039619b..d501c87 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/IAnimation.java @@ -84,4 +84,21 @@ default FirstPersonConfiguration getFirstPersonConfiguration() { default boolean canRemove() { return false; } + + //TODO Maybe make these two methods no longer default the next breaking change + /** + * Useful for compatibility patches. + * You can see which parts are modified by the mod. + */ + default boolean modifiesPart(String name) { + return false; + } + + /** + * Useful for compatibility patches. + * You can see which parts are being bent by the mod. + */ + default boolean bendsPart(String name) { + return false; + } } diff --git a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java index 7b9ef2f..9f56bf5 100644 --- a/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java +++ b/core/src/main/java/com/zigythebird/playeranimcore/animation/layered/ModifierLayer.java @@ -178,6 +178,16 @@ public void setupAnim(AnimationData state) { return IAnimation.super.getFirstPersonConfiguration(); } + @Override + public boolean modifiesPart(String name) { + return animation != null && animation.modifiesPart(name); + } + + @Override + public boolean bendsPart(String name) { + return animation != null && animation.bendsPart(name); + } + @Override public String toString() { return "ModifierLayer{" +