Fixes to animations

This commit is contained in:
luisc committed 2024-04-02 15:19:27 -05:00
1 parent d055d434df
commit 403b6c5d32
3 files changed
+13 -6

No files matched your search

@@ -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.
}
}
}});
@@ -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);
}
}
@@ -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;