diff --git a/assets/Models/creatures/viewmodel.glb b/assets/Models/creatures/viewmodel.glb index 6ba1d2cf..91f5103b 100644 Binary files a/assets/Models/creatures/viewmodel.glb and b/assets/Models/creatures/viewmodel.glb differ diff --git a/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java b/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java index 03557d1e..32a6e2a4 100644 --- a/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java +++ b/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java @@ -158,20 +158,24 @@ public class StateTransitionUtil { if(state.getAnimation != null && state.getAnimation.get() != null){ animation = state.getAnimation.get(); } - - //Main simulation - if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true && animation != null){ + + + if(animation == null){ + state.startedAnimation = true; + if(state.onComplete != null){ + state.onComplete.run(); + } + } else if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true){ //state transition if this isn't set to loop state.onComplete.run(); state.startedAnimation = false; - } else if(state.animation != null && (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animation))){ + } else if(!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animation)){ //play animation for state - poseActor.playAnimation(animation); + if(animation != null){ + poseActor.playAnimation(animation); + } poseActor.incrementAnimationTime(0.0001); state.startedAnimation = true; - } else if(state.animation == null && state.onComplete != null){ - state.onComplete.run(); - state.startedAnimation = false; } } } diff --git a/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java b/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java index bb8d3396..b8792d79 100644 --- a/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java +++ b/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java @@ -50,7 +50,13 @@ public class ServerBlockTree implements BehaviorTree { this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{ StateTransitionUtilItem.create( BlockState.WIND_UP, - () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();}, + () -> { + BlockVariant variant = this.blockSystem.getBlockVariant(this.currentBlockVariant); + if(variant != null){ + return variant.getWindUpAnimation(); + } + return null; + }, null, () -> {this.setState(BlockState.BLOCKING);} ), diff --git a/src/main/java/electrosphere/server/poseactor/PoseActor.java b/src/main/java/electrosphere/server/poseactor/PoseActor.java index 5655665a..8fcd6181 100644 --- a/src/main/java/electrosphere/server/poseactor/PoseActor.java +++ b/src/main/java/electrosphere/server/poseactor/PoseActor.java @@ -101,12 +101,15 @@ public class PoseActor { /** * Gets whether the animation is currently playing or not - * @param animationName The animation + * @param animationData The animation * @return True if the animation is playing, false otherwise */ - public boolean isPlayingAnimation(TreeDataAnimation animationName){ + public boolean isPlayingAnimation(TreeDataAnimation animationData){ + if(animationData == null){ + return false; + } for(ActorAnimationMask mask : animationQueue){ - if(mask.getAnimationName().contains(animationName.getNameThirdPerson())){ + if(mask.getAnimationName().contains(animationData.getNameThirdPerson())){ return true; } }