From 403b6c5d32e8801549ac2059e7ed8c6ff2fce8e3 Mon Sep 17 00:00:00 2001 From: luisc Date: Tue, 2 Apr 2024 15:19:27 -0500 Subject: [PATCH] Fixes to animations --- src/main/java/noppes/npcs/CommonProxy.java | 1 - .../npcs/controllers/data/AnimationData.java | 15 +++++++++++---- .../npcs/controllers/data/PlayerDataScript.java | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/noppes/npcs/CommonProxy.java b/src/main/java/noppes/npcs/CommonProxy.java index 5bf78ad28..db8c14d8a 100644 --- a/src/main/java/noppes/npcs/CommonProxy.java +++ b/src/main/java/noppes/npcs/CommonProxy.java @@ -61,7 +61,6 @@ public class CommonProxy implements IGuiHandler { serverPlayingAnimations.removeIf(CommonProxy.this::removeAnimation); } } catch (Exception ignored) { - //Must ignore exceptions in this thread so a single animation error doesn't break all animations. } } }}); diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index d965d3c74..0ddf23d92 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -63,9 +63,16 @@ public class AnimationData implements IAnimationData { } public IAnimatable getEntity() { + IEntity entity = NpcAPI.Instance().getIEntity(this.getMCEntity()); + if (entity instanceof IAnimatable) { + return (IAnimatable) entity; + } + return null; + } + + public EntityLivingBase getMCEntity() { if (this.parent instanceof DataDisplay) { - EntityNPCInterface npc = ((DataDisplay)this.parent).npc; - return (ICustomNpc) NpcAPI.Instance().getIEntity(npc); + return ((DataDisplay) this.parent).npc; } else { EntityPlayer player; if (this.parent instanceof PlayerData) { @@ -73,7 +80,7 @@ public class AnimationData implements IAnimationData { } else { player = (EntityPlayer) this.parent; } - return (IPlayer) NpcAPI.Instance().getIEntity(player); + return player; } } @@ -181,7 +188,7 @@ public class AnimationData implements IAnimationData { animationData.allowAnimation = prevEnabled; synchronized (CommonProxy.serverPlayingAnimations) { - if (animationData.animationEntity != null && !animationData.animationEntity.worldObj.isRemote) { + if (animationData.animationEntity != null && !animationData.animationEntity.worldObj.isRemote && animation != null) { CommonProxy.serverPlayingAnimations.add(animation); } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java index 85096dfe0..2f1b88478 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java @@ -1,6 +1,7 @@ package noppes.npcs.controllers.data; import com.google.common.base.Preconditions; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -97,7 +98,7 @@ public class PlayerDataScript implements INpcScriptHandler { } public boolean isClient() { - return this.player.isClientWorld(); + return FMLCommonHandler.instance().getEffectiveSide().isClient(); } public boolean getEnabled() { return ScriptController.Instance.playerScripts.enabled;