@Override
 public void readData(SpoutInputStream input) throws IOException {
   super.readData(input);
   stack.setTypeId(input.readInt());
   stack.setAmount((int) input.readShort());
   stack.setDurability(input.readShort());
   depth = input.readInt();
   renderAmount = input.readBoolean();
 }
  @Override
  public void writeData(SpoutOutputStream output) throws IOException {
    super.writeData(output);
    output.writeInt(stack.getTypeId());
    output.writeShort((short) stack.getAmount());
    output.writeShort(stack.getDurability());
    output.writeInt(depth);
    output.writeBoolean(renderAmount);

    if (stack.hasItemMeta() && stack.getItemMeta().hasDisplayName()) {
      output.writeBoolean(true);
      output.writeString(stack.getItemMeta().getDisplayName());
    } else {
      output.writeBoolean(false);
    }

    if (stack.hasItemMeta() && stack.getItemMeta().hasLore()) {
      output.writeBoolean(true);
      output.writeInt(stack.getItemMeta().getLore().size());
      for (String l : stack.getItemMeta().getLore()) {
        output.writeString(l);
      }
    } else {
      output.writeBoolean(false);
    }

    if (stack.hasItemMeta() && stack.getItemMeta().hasEnchants()) {
      output.writeBoolean(true);
      output.writeInt(stack.getItemMeta().getEnchants().size());
      for (Entry e : stack.getItemMeta().getEnchants().entrySet()) {
        output.writeInt(((Enchantment) e.getKey()).getId());
        output.writeInt((Integer) e.getValue());
      }
    } else {
      output.writeBoolean(false);
    }
  }