Advertisement
Camellias_

Untitled

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