Advertisement
TitanChase

Untitled

Mar 7th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. @Override
  2.     public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer)
  3.     {
  4.         if (!doTransfer)
  5.             return null;
  6.         Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs = recipeLayout.getItemStacks().getGuiIngredients();
  7.         JsonRecipe recipe = new JsonRecipe(inputs.size() - 1);
  8.         List<ItemStack> stacks = new ArrayList<ItemStack>();
  9.         for (int i = 0; i < inputs.size(); i++)
  10.         {
  11.             if (!inputs.get(i).isInput())
  12.             {
  13.                 recipe.result = OreDictHelper.getOreDictEquivalent(inputs.get(i).getAllIngredients());
  14.                 recipe.count = inputs.get(i).getAllIngredients().get(0).getCount();
  15.             }
  16.         }
  17.         for (Slot slot : container.inventorySlots)
  18.         {
  19.             if (slot.inventory instanceof InventoryCrafting)
  20.             {
  21.                 IGuiIngredient<ItemStack> ingredient = inputs.get(slot.getSlotIndex() + 1);
  22.  
  23.                 if (ingredient != null && ingredient.getAllIngredients().size() > 0)
  24.                 {
  25.                     int x = slot.getSlotIndex() / recipe.recipeSize;
  26.                     int y = slot.getSlotIndex() % recipe.recipeSize;
  27.                     recipe.recipe[x][y] = OreDictHelper.getOreDictEquivalent(ingredient.getAllIngredients());
  28.                     stacks.add(ingredient.getAllIngredients().get(0));
  29.                 }
  30.                 else
  31.                 {
  32.                     stacks.add(null);
  33.                 }
  34.             }
  35.         }
  36.         if (recipe.hasResult())
  37.         {
  38.             File file = new File("config/" + References.Mod.Id + "/exportRecipe.json");
  39.             FileIOHelper.CreateFile(file);
  40.             FileIOHelper.WriteFile(file, recipe.toJson());
  41.             PlayerUtils.sendMessage(player, recipe.result + ": written to exportRecipe.json");
  42.         }
  43.         return null;
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement