Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //RECIPE CLASS
- package lyesoussaiden.satanicofferings.init.classes.recipes;
- import java.util.HashMap;
- import java.util.Hashtable;
- import java.util.Map;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- public class SatanicOfferingsRecipes {
- public static class SatanicAltar
- {
- private static int InputSlotCount = 4;
- /* 0 = Blood Énergy Cost
- * 1 = Duration of Revision
- * 2 = Output Item (AKA The Result) Stack-Size
- */
- private static Map<Item[], int[]> intVals = new HashMap<Item[], int[]>();
- private static Map<Item[], int[]> recipeSizes = new HashMap<Item[], int[]>();
- private static Map<Item[], Item> recipes = new HashMap<Item[], Item>();
- public static void addRecipe(ItemStack output, ItemStack[] recipe, int bÉCost, int duration)
- {
- //Null Checks
- if(output == null || recipe == null || bÉCost <= 0 || duration <= 0)
- {
- System.out.println("NOTE! NULL PARAMETER DETECTED AND RECIPE NOT ADDED!");
- return;
- }
- //Get a recipe and set a temporary variable to the recipe + recipe attributes
- Item outputItem = output.getItem();
- int outputItemSize = output.stackSize;
- Item[] outputRecipe = new Item[InputSlotCount];
- int[] outputSize = new int[InputSlotCount];
- for(int i = 0; i < InputSlotCount; i++)
- {
- if(recipe[i] != null)
- {
- outputRecipe[i] = recipe[i].getItem();
- outputSize[i] = recipe[i].stackSize;
- }
- else
- {
- outputRecipe[i] = null;
- outputSize[i] = 0;
- }
- }
- //Put recipes and other variables within the Hashtables above.
- recipes.put(outputRecipe, outputItem);
- recipeSizes.put(outputRecipe, outputSize);
- intVals.put(outputRecipe, new int[] {bÉCost, duration, outputItemSize});
- }
- public static ItemStack getOutputFromRecipe(ItemStack[] recipe)
- {
- if(recipe != null)
- {
- //Get a recipe and set a temporary variable to the recipe + recipe attributes
- Item[] inputRecipe = new Item[InputSlotCount];
- int[] inputSize = new int[InputSlotCount];
- for(int i = 0; i < InputSlotCount; i++)
- {
- if(recipe[i] != null)
- {
- inputRecipe[i] = recipe[i].getItem();
- inputSize[i] = recipe[i].stackSize;
- }
- else
- {
- inputRecipe[i] = null;
- inputSize[i] = 0;
- }
- }
- Item outputItem = recipes.get(inputRecipe);
- int outputItemSize = intVals.get(inputRecipe)[2];
- if(outputItem != null && outputItemSize > 0)
- return new ItemStack(outputItem, outputItemSize);
- }
- return null;
- }
- }
- }
- //METHODS CALLING IT
- /*SATANIC ALTAR RECIPES*/
- //Obsidian Fragment
- SatanicOfferingsRecipes.SatanicAltar.addRecipe(new ItemStack(ModItems.obsidianFragment, 4), new ItemStack[] {null, new ItemStack(Blocks.obsidian, 1), new ItemStack(Items.flint, 1), null}, 600, 10);
- ItemStack debugOutput = SatanicOfferingsRecipes.SatanicAltar.getOutputFromRecipe(new ItemStack[] {null, new ItemStack(Blocks.obsidian, 1), new ItemStack(Items.flint, 1), null});
- System.out.println(debugOutput.getDisplayName());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement