Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.fejcraft.FejCraftRPG;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import com.fejcraft.FejCraftRPG.FejRecipeTypes.FejRecipeShaped;
- import net.minecraft.block.Block;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemArmor;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.CraftingManager;
- import net.minecraft.item.crafting.ShapedRecipes;
- public class FejRecipeHandler {
- public final static int LEVEL_REQUIRED_DIAMOND_ARMOR = 5;
- public static void removeRecipes(List recipeList)
- {
- for(int i = 0; i < recipeList.size(); i++)
- {
- if(recipeList.get(i) instanceof ShapedRecipes)
- {
- if(isItemStackOfType(((ShapedRecipes)recipeList.get(i)).getRecipeOutput() , Item.helmetDiamond) ) {
- recipeList.remove(i);
- addFejRecipe(LEVEL_REQUIRED_DIAMOND_ARMOR,new ItemStack(ItemArmor.helmetDiamond), "OOO","O O", 'O', new ItemStack(Item.diamond));
- }
- }
- }
- }
- //Slightly edited from CraftingManager, only change is that it uses FejRecipeShaped instead of ShapedRecipes and adds an integer parameter to fit
- public static FejRecipeShaped addFejRecipe(int levelRequired, ItemStack par1ItemStack, Object ... par2ArrayOfObj)
- {
- String s = "";
- int i = 0;
- int j = 0;
- int k = 0;
- if (par2ArrayOfObj[i] instanceof String[])
- {
- String[] astring = (String[])((String[])par2ArrayOfObj[i++]);
- for (int l = 0; l < astring.length; ++l)
- {
- String s1 = astring[l];
- ++k;
- j = s1.length();
- s = s + s1;
- }
- }
- else
- {
- while (par2ArrayOfObj[i] instanceof String)
- {
- String s2 = (String)par2ArrayOfObj[i++];
- ++k;
- j = s2.length();
- s = s + s2;
- }
- }
- HashMap hashmap;
- for (hashmap = new HashMap(); i < par2ArrayOfObj.length; i += 2)
- {
- Character character = (Character)par2ArrayOfObj[i];
- ItemStack itemstack1 = null;
- if (par2ArrayOfObj[i + 1] instanceof Item)
- {
- itemstack1 = new ItemStack((Item)par2ArrayOfObj[i + 1]);
- }
- else if (par2ArrayOfObj[i + 1] instanceof Block)
- {
- itemstack1 = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, 32767);
- }
- else if (par2ArrayOfObj[i + 1] instanceof ItemStack)
- {
- itemstack1 = (ItemStack)par2ArrayOfObj[i + 1];
- }
- hashmap.put(character, itemstack1);
- }
- ItemStack[] aitemstack = new ItemStack[j * k];
- for (int i1 = 0; i1 < j * k; ++i1)
- {
- char c0 = s.charAt(i1);
- if (hashmap.containsKey(Character.valueOf(c0)))
- {
- aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();
- }
- else
- {
- aitemstack[i1] = null;
- }
- }
- FejRecipeShaped shapedrecipes = new FejRecipeShaped(j, k, aitemstack, par1ItemStack, levelRequired);
- CraftingManager.getInstance().getRecipeList().add(shapedrecipes);
- return shapedrecipes;
- }
- private static boolean isItemStackOfType(ItemStack stack, Item item)
- {
- if(stack.getItem().itemID == item.itemID)
- return true;
- else
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement