private void writeInventory(AMDataWriter writer) {
   for (ItemStack stack : inventory) {
     if (stack == null) {
       writer.add(false);
       continue;
     } else {
       writer.add(true);
       writer.add(stack);
     }
   }
 }
  @SubscribeEvent
  public void onPlayerLogin(PlayerLoggedInEvent event) {
    if (hasAA(event.player)) {
      AMNetHandler.INSTANCE.requestClientAuras((EntityPlayerMP) event.player);
    }

    int[] disabledSkills = SkillTreeManager.instance.getDisabledSkillIDs();

    AMDataWriter writer = new AMDataWriter();
    writer.add(AMCore.config.getSkillTreeSecondaryTierCap()).add(disabledSkills);
    writer.add(AMCore.config.getManaCap());
    byte[] data = writer.generate();

    AMNetHandler.INSTANCE.syncLoginData((EntityPlayerMP) event.player, data);
    if (ServerTickHandler.lastWorldName != null)
      AMNetHandler.INSTANCE.syncWorldName(
          (EntityPlayerMP) event.player, ServerTickHandler.lastWorldName);
  }
  private void addItemToRecipe(ItemStack stack) {
    allAddedItems.add(stack);
    currentAddedItems.add(stack);

    if (!worldObj.isRemote) {
      AMDataWriter writer = new AMDataWriter();
      writer.add(xCoord);
      writer.add(yCoord);
      writer.add(zCoord);
      writer.add(COMPONENT_ADDED);
      writer.add(stack);
      AMNetHandler.INSTANCE.sendPacketToAllClientsNear(
          worldObj.provider.dimensionId,
          xCoord,
          yCoord,
          zCoord,
          32,
          AMPacketIDs.CRAFTING_ALTAR_DATA,
          writer.generate());
    }

    if (matchCurrentRecipe()) {
      currentAddedItems.clear();
      return;
    }
  }
  private void setCrafting(boolean crafting) {
    this.isCrafting = crafting;
    if (!worldObj.isRemote) {
      AMDataWriter writer = new AMDataWriter();
      writer.add(xCoord);
      writer.add(yCoord);
      writer.add(zCoord);
      writer.add(CRAFTING_CHANGED);
      writer.add(crafting);
      AMNetHandler.INSTANCE.sendPacketToAllClientsNear(
          worldObj.provider.dimensionId,
          xCoord,
          yCoord,
          zCoord,
          32,
          AMPacketIDs.CRAFTING_ALTAR_DATA,
          writer.generate());
    }
    if (crafting) {
      allAddedItems.clear();
      currentAddedItems.clear();

      spellDef.clear();
      for (ArrayList<KeyValuePair<ISpellPart, byte[]>> groups : shapeGroups) groups.clear();

      // find otherworld auras
      IPowerNode[] nodes =
          PowerNodeRegistry.For(worldObj)
              .getAllNearbyNodes(worldObj, new AMVector3(this), PowerTypes.DARK);
      for (IPowerNode node : nodes) {
        if (node instanceof TileEntityOtherworldAura) {
          ((TileEntityOtherworldAura) node).setActive(true, this);
          break;
        }
      }
    }
  }