Posted June 9, 201411 yr So basically like the title says, I have made a custom crafting table that is a 5x5 grid. Everything works fine apart from the shapeless recipes. They will not work unless they are in the original 3x3 grid's location(Top Left hand corner). I have made the changes to the For loops to have it cycle through a 5x5 instead of a 3x3, yet it still doesn't work. From what I can tell the shaped recipes work fine. Here is my ShaplessRecipes Class. package com.bigbaddevil7.rustic.crafting; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; public class PrototypingTableShapelessRecipes implements IRecipe { /** Is the ItemStack that you get when craft the recipe. */ private final ItemStack recipeOutput; /** Is a List of ItemStack that composes the recipe. */ public final List recipeItems; private static final String __OBFID = "CL_00000094"; public PrototypingTableShapelessRecipes(ItemStack par1ItemStack, List par2List) { this.recipeOutput = par1ItemStack; this.recipeItems = par2List; } public ItemStack getRecipeOutput() { return this.recipeOutput; } /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { ArrayList arraylist = new ArrayList(this.recipeItems); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i); if (itemstack != null) { boolean flag = false; Iterator iterator = arraylist.iterator(); while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack)iterator.next(); if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == 32767 || itemstack.getItemDamage() == itemstack1.getItemDamage())) { flag = true; arraylist.remove(itemstack1); break; } } if (!flag) { return false; } } } } return arraylist.isEmpty(); } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) { return this.recipeOutput.copy(); } /** * Returns the size of the recipe area */ public int getRecipeSize() { return this.recipeItems.size(); } } Not sure what else you may need. I'll provide the manager as well. package com.bigbaddevil7.rustic.crafting; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import com.bigbaddevil7.rustic.Rustic; import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; public class PrototypingTableCraftingManager { /** The static instance of this class */ private static final PrototypingTableCraftingManager instance = new PrototypingTableCraftingManager(); /** A list of all the recipes added */ private List recipes = new ArrayList(); private static final String __OBFID = "CL_00000090"; /** * Returns the static instance of this class */ public static final PrototypingTableCraftingManager getInstance() { /** The static instance of this class */ return instance; } private PrototypingTableCraftingManager() { recipes = new ArrayList(); this.addRecipe(new ItemStack(Rustic.prototypingTable, 1), new Object[] {"S", "S", "S", "S", "S", 'S', Items.stick}); this.addShapelessRecipe(new ItemStack(Rustic.formedCopper), new ItemStack(Rustic.hammer, 1, OreDictionary.WILDCARD_VALUE), Rustic.ingotCopper); Collections.sort(this.recipes, new PrototypingTableRecipeSorter(this)); } public PrototypingTableShapedRecipes addRecipe(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; } } PrototypingTableShapedRecipes shapedrecipes = new PrototypingTableShapedRecipes(j, k, aitemstack, par1ItemStack); this.recipes.add(shapedrecipes); return shapedrecipes; } public void addShapelessRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj) { ArrayList arraylist = new ArrayList(); Object[] aobject = par2ArrayOfObj; int i = par2ArrayOfObj.length; for (int j = 0; j < i; ++j) { Object object1 = aobject[j]; if (object1 instanceof ItemStack) { arraylist.add(((ItemStack)object1).copy()); } else if (object1 instanceof Item) { arraylist.add(new ItemStack((Item)object1)); } else { if (!(object1 instanceof Block)) { throw new RuntimeException("Invalid shapeless recipe!"); } arraylist.add(new ItemStack((Block)object1)); } } this.recipes.add(new ShapelessRecipes(par1ItemStack, arraylist)); } public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; int j; for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) { ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); if (itemstack2 != null) { if (i == 0) { itemstack = itemstack2; } if (i == 1) { itemstack1 = itemstack2; } ++i; } } if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) { Item item = itemstack.getItem(); int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); int l = j1 + k + item.getMaxDamage() * 5 / 100; int i1 = item.getMaxDamage() - l; if (i1 < 0) { i1 = 0; } return new ItemStack(itemstack.getItem(), 1, i1); } else { for (j = 0; j < this.recipes.size(); ++j) { IRecipe irecipe = (IRecipe)this.recipes.get(j); if (irecipe.matches(par1InventoryCrafting, par2World)) { return irecipe.getCraftingResult(par1InventoryCrafting); } } return null; } } /** * returns the List<> of all recipes */ public List getRecipeList() { return this.recipes; } } [/spoiler] No Errors are thrown.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.