diff --git a/src/main/java/noppes/npcs/AnimationData.java b/src/main/java/noppes/npcs/AnimationData.java index 828e1a873..719f5a34a 100644 --- a/src/main/java/noppes/npcs/AnimationData.java +++ b/src/main/java/noppes/npcs/AnimationData.java @@ -23,15 +23,12 @@ public class AnimationData implements IAnimationData { } public void updateClient() { + NBTTagCompound compound = new NBTTagCompound(); + compound = this.writeToNBT(compound); + compound.setTag("Animation",this.animation.writeToNBT()); if (parent instanceof PlayerData) { - NBTTagCompound compound = new NBTTagCompound(); - this.writeToNBT(compound); - compound.setTag("Animation",this.animation.writeToNBT()); Server.sendToAll(EnumPacketClient.UPDATE_ANIMATIONS, compound, ((PlayerData) parent).player.getCommandSenderName()); } else if (parent instanceof DataDisplay) { - NBTTagCompound compound = new NBTTagCompound(); - this.writeToNBT(compound); - compound.setTag("Animation",this.animation.writeToNBT()); compound.setInteger("EntityId",((DataDisplay) parent).npc.getEntityId()); Server.sendAssociatedData(((DataDisplay) parent).npc, EnumPacketClient.UPDATE_ANIMATIONS, compound); } diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index e577c84f3..bd73c46d8 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -308,11 +308,15 @@ public class PacketHandlerClient extends PacketHandlerServer{ AnimationData data; if (!Client.playerAnimations.containsKey(player.getUniqueID())) { data = new AnimationData(player); - data.readFromNBT(compound.getCompoundTag("Animation")); + data.readFromNBT(compound); } else { data = Client.playerAnimations.get(player.getUniqueID()); - data.readFromNBT(compound.getCompoundTag("Animation")); + data.readFromNBT(compound); } + if (data.animation == null) { + data.animation = new Animation(); + } + data.animation.readFromNBT(compound.getCompoundTag("Animation")); Client.playerAnimations.put(player.getUniqueID(), data); } }