Camellias_

Untitled

Jul 30th, 2019
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. package com.camellias.voidaicarcania.api.registry;
  2.  
  3. import java.util.Map;
  4.  
  5. import org.apache.commons.lang3.tuple.MutableTriple;
  6. import org.apache.commons.lang3.tuple.Triple;
  7.  
  8. import com.google.common.collect.HashBasedTable;
  9. import com.google.common.collect.Table;
  10.  
  11. import net.minecraft.item.ItemStack;
  12.  
  13. public class VoidaicAltarRecipes
  14. {
  15.     public static final VoidaicAltarRecipes INSTANCE = new VoidaicAltarRecipes();
  16.     private final Table<Triple<ItemStack, ItemStack, ItemStack>, Integer, ItemStack> recipes = HashBasedTable.create();
  17.    
  18.     /**
  19.      * Used to add shaped recipes to the Voidaic Altar.
  20.      *
  21.      * @param input1 - The first ingredient.
  22.      * @param input2 - The second ingredient.
  23.      * @param input3 - The third ingredient.
  24.      * @param voidEssenceCost - How much Void Essence the recipe requires. Has to be higher than 0, else the recipe won't work.
  25.      * @param result - The resulting ItemStack of the recipe.
  26.      * @return
  27.      */
  28.     public void addRecipe(ItemStack input1, ItemStack input2, ItemStack input3, int voidEssenceCost, ItemStack result)
  29.     {
  30.         Triple ingredients = new MutableTriple<>(input1, input2, input3);
  31.         recipes.put(ingredients, voidEssenceCost, result);
  32.     }
  33.    
  34.     public Table<Triple<ItemStack, ItemStack, ItemStack>, Integer, ItemStack> getRecipes()
  35.     {
  36.         return recipes;
  37.     }
  38.    
  39.     public ItemStack getIngredient1()
  40.     {
  41.         for(Triple<ItemStack, ItemStack, ItemStack> triple: recipes.rowKeySet())
  42.         {
  43.             return triple.getLeft();
  44.         }
  45.        
  46.         return null;
  47.     }
  48.    
  49.     public ItemStack getIngredient2()
  50.     {
  51.         for(Triple<ItemStack, ItemStack, ItemStack> triple: recipes.rowKeySet())
  52.         {
  53.             return triple.getMiddle();
  54.         }
  55.        
  56.         return null;
  57.     }
  58.    
  59.     public ItemStack getIngredient3()
  60.     {
  61.         for(Triple<ItemStack, ItemStack, ItemStack> triple: recipes.rowKeySet())
  62.         {
  63.             return triple.getRight();
  64.         }
  65.        
  66.         return null;
  67.     }
  68.    
  69.     public int getVoidEssenceCost(ItemStack input1, ItemStack input2, ItemStack input3)
  70.     {
  71.         Triple ingredients = new MutableTriple<>(input1, input2, input3);
  72.         Map<Integer, ItemStack> row = recipes.row(ingredients);
  73.        
  74.         for(int voidEssence : row.keySet())
  75.         {
  76.             System.out.println(voidEssence);
  77.             return voidEssence;
  78.         }
  79.        
  80.         return 0;
  81.     }
  82.    
  83.     public ItemStack getRecipeResult(ItemStack stack1, ItemStack stack2, ItemStack stack3, int voidEssenceCost)
  84.     {
  85.         Triple ingredients = new MutableTriple<>(stack1, stack2, stack3);
  86.        
  87.         return recipes.get(ingredients, voidEssenceCost);
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment