From 795bdcd427e5f8c9c0952af61370dfd07f2d8f5a Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sat, 17 Oct 2020 13:02:09 +0100 Subject: [PATCH] Fix player animations being applied to all instances of the model --- .../client/animation/PlayerAnimator.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/electroblob/wizardry/client/animation/PlayerAnimator.java b/src/main/java/electroblob/wizardry/client/animation/PlayerAnimator.java index 84446682..e0acd4dc 100644 --- a/src/main/java/electroblob/wizardry/client/animation/PlayerAnimator.java +++ b/src/main/java/electroblob/wizardry/client/animation/PlayerAnimator.java @@ -143,16 +143,12 @@ public class PlayerAnimator { } } - boolean flag = false; - for(Animation animation : animations){ if(animation.shouldDisplay(player, firstPerson)){ boolean autoRotateSecondLayer = animation.autoRotateSecondLayer(player, firstPerson); - flag = true; - for(ModelBiped model : playerLayerModels.get(renderer)){ animation.setRotationAngles(player, model, partialTicks, firstPerson); @@ -164,17 +160,6 @@ public class PlayerAnimator { } } - if(!flag){ - for(ModelBiped model : playerLayerModels.get(renderer)){ - for(ModelRenderer box : model.boxList){ // For ModelPlayer, this will include the second layer - // Some models have extra boxes, they (probably) don't need wrapping but we need this check! - if(box instanceof ModelRendererExtended){ - ((ModelRendererExtended)box).resetRotation(); - } - } - } - } - } /** Rotates the second layer boxes of the given (wrapped) player model to match the first layer. */ @@ -216,9 +201,20 @@ public class PlayerAnimator { updateModels(event.getEntityPlayer(), event.getRenderer(), event.getPartialRenderTick(), false); } -// @SubscribeEvent -// public static void onRenderPlayerPostEvent(RenderPlayerEvent.Post event){ - // TODO: Would we ever need to unwrap the models? -// } + @SubscribeEvent + public static void onRenderPlayerPostEvent(RenderPlayerEvent.Post event){ + + if(!Wizardry.settings.spellcastingAnimations) return; + + for(ModelBiped model : playerLayerModels.get(event.getRenderer())){ + for(ModelRenderer box : model.boxList){ // For ModelPlayer, this will include the second layer + // Some models have extra boxes, they (probably) don't need wrapping but we need this check! + if(box instanceof ModelRendererExtended){ + ((ModelRendererExtended)box).resetRotation(); + } + } + } + + } }