@Override
 public void setItem(int index, ItemStack item) {
   if (item != null && item.getTypeId() == 0) {
     item = null;
   }
   if (index == 0) {
     this.result.setItem(index, (item == null ? null : CraftItemStack.asNMSCopy(item)));
   } else {
     this.inventory.setItem(
         (index - this.result.getSize()), (item == null ? null : CraftItemStack.asNMSCopy(item)));
   }
 }
 @Override
 public void setResult(ItemStack item) {
   net.minecraft.server.v1_6_R3.ItemStack[] contents = this.result.getContents();
   if (item == null || item.getTypeId() <= 0) {
     contents[0] = null;
   } else {
     contents[0] = CraftItemStack.asNMSCopy(item);
   }
 }
  @Override
  public void setMatrix(ItemStack[] contents) {
    if (this.inventory.getContents().length != contents.length) {
      throw new IllegalArgumentException(
          "Invalid inventory size; expected " + this.inventory.getContents().length);
    }

    net.minecraft.server.v1_6_R3.ItemStack[] mcItems = this.inventory.getContents();

    for (int i = 0; i < contents.length; i++) {
      ItemStack item = contents[i];
      if (item == null || item.getTypeId() <= 0) {
        mcItems[i] = null;
      } else {
        mcItems[i] = CraftItemStack.asNMSCopy(item);
      }
    }
  }