public static void removeShapelessRecipe(ItemStack resultItem) { List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); for (int i = 0; i < recipes.size(); i++) { IRecipe tmpRecipe = recipes.get(i); if (tmpRecipe instanceof ShapelessRecipes) { ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe; ItemStack recipeResult = recipe.getRecipeOutput(); if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) { recipes.remove(i--); } } } }
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) { if (recipe.recipeItems == null) // because some mod subclasses actually do this { return null; } return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput()); }
@SuppressWarnings("unchecked") public static void initVanillaEntries() { if (!hasInit) { registerOre("logWood", new ItemStack(Blocks.log, 1, WILDCARD_VALUE)); registerOre("logWood", new ItemStack(Blocks.log2, 1, WILDCARD_VALUE)); registerOre("plankWood", new ItemStack(Blocks.planks, 1, WILDCARD_VALUE)); registerOre("slabWood", new ItemStack(Blocks.wooden_slab, 1, WILDCARD_VALUE)); registerOre("stairWood", Blocks.oak_stairs); registerOre("stairWood", Blocks.spruce_stairs); registerOre("stairWood", Blocks.birch_stairs); registerOre("stairWood", Blocks.jungle_stairs); registerOre("stairWood", Blocks.acacia_stairs); registerOre("stairWood", Blocks.dark_oak_stairs); registerOre("stickWood", Items.stick); registerOre("treeSapling", new ItemStack(Blocks.sapling, 1, WILDCARD_VALUE)); registerOre("treeLeaves", new ItemStack(Blocks.leaves, 1, WILDCARD_VALUE)); registerOre("treeLeaves", new ItemStack(Blocks.leaves2, 1, WILDCARD_VALUE)); registerOre("oreGold", Blocks.gold_ore); registerOre("oreIron", Blocks.iron_ore); registerOre("oreLapis", Blocks.lapis_ore); registerOre("oreDiamond", Blocks.diamond_ore); registerOre("oreRedstone", Blocks.redstone_ore); registerOre("oreEmerald", Blocks.emerald_ore); registerOre("oreQuartz", Blocks.quartz_ore); registerOre("oreCoal", Blocks.coal_ore); registerOre("blockGold", Blocks.gold_block); registerOre("blockIron", Blocks.iron_block); registerOre("blockLapis", Blocks.lapis_block); registerOre("blockDiamond", Blocks.diamond_block); registerOre("blockRedstone", Blocks.redstone_block); registerOre("blockEmerald", Blocks.emerald_block); registerOre("blockQuartz", Blocks.quartz_block); registerOre("blockCoal", Blocks.coal_block); registerOre("blockGlassColorless", Blocks.glass); registerOre("blockGlass", Blocks.glass); registerOre("blockGlass", new ItemStack(Blocks.stained_glass, 1, WILDCARD_VALUE)); // blockGlass{Color} is added below with dyes registerOre("paneGlassColorless", Blocks.glass_pane); registerOre("paneGlass", Blocks.glass_pane); registerOre("paneGlass", new ItemStack(Blocks.stained_glass_pane, 1, WILDCARD_VALUE)); // paneGlass{Color} is added below with dyes registerOre("ingotIron", Items.iron_ingot); registerOre("ingotGold", Items.gold_ingot); registerOre("ingotBrick", Items.brick); registerOre("ingotBrickNether", Items.netherbrick); registerOre("nuggetGold", Items.gold_nugget); registerOre("gemDiamond", Items.diamond); registerOre("gemEmerald", Items.emerald); registerOre("gemQuartz", Items.quartz); registerOre("dustRedstone", Items.redstone); registerOre("dustGlowstone", Items.glowstone_dust); registerOre("gemLapis", new ItemStack(Items.dye, 1, 4)); registerOre("slimeball", Items.slime_ball); registerOre("glowstone", Blocks.glowstone); registerOre("cropWheat", Items.wheat); registerOre("cropPotato", Items.potato); registerOre("cropCarrot", Items.carrot); registerOre("stone", Blocks.stone); registerOre("cobblestone", Blocks.cobblestone); registerOre("sandstone", new ItemStack(Blocks.sandstone, 1, WILDCARD_VALUE)); registerOre("sand", new ItemStack(Blocks.sand, 1, WILDCARD_VALUE)); registerOre("dye", new ItemStack(Items.dye, 1, WILDCARD_VALUE)); registerOre("record", Items.record_13); registerOre("record", Items.record_cat); registerOre("record", Items.record_blocks); registerOre("record", Items.record_chirp); registerOre("record", Items.record_far); registerOre("record", Items.record_mall); registerOre("record", Items.record_mellohi); registerOre("record", Items.record_stal); registerOre("record", Items.record_strad); registerOre("record", Items.record_ward); registerOre("record", Items.record_11); registerOre("record", Items.record_wait); registerOre("chest", Blocks.chest); registerOre("chest", Blocks.ender_chest); registerOre("chest", Blocks.trapped_chest); registerOre("chestWood", Blocks.chest); registerOre("chestEnder", Blocks.ender_chest); registerOre("chestTrapped", Blocks.trapped_chest); } // Build our list of items to replace with ore tags Map<ItemStack, String> replacements = new HashMap<ItemStack, String>(); replacements.put(new ItemStack(Items.stick), "stickWood"); replacements.put(new ItemStack(Blocks.planks), "plankWood"); replacements.put(new ItemStack(Blocks.planks, 1, WILDCARD_VALUE), "plankWood"); replacements.put(new ItemStack(Blocks.wooden_slab, 1, WILDCARD_VALUE), "slabWood"); replacements.put(new ItemStack(Blocks.stone), "stone"); // replacements.put(new ItemStack(Blocks.stone, 1, WILDCARD_VALUE), "stone"); replacements.put(new ItemStack(Blocks.cobblestone), "cobblestone"); replacements.put(new ItemStack(Blocks.cobblestone, 1, WILDCARD_VALUE), "cobblestone"); replacements.put(new ItemStack(Items.gold_ingot), "ingotGold"); replacements.put(new ItemStack(Items.iron_ingot), "ingotIron"); replacements.put(new ItemStack(Items.diamond), "gemDiamond"); replacements.put(new ItemStack(Items.emerald), "gemEmerald"); replacements.put(new ItemStack(Items.redstone), "dustRedstone"); replacements.put(new ItemStack(Items.glowstone_dust), "dustGlowstone"); replacements.put(new ItemStack(Blocks.glowstone), "glowstone"); replacements.put(new ItemStack(Items.slime_ball), "slimeball"); replacements.put(new ItemStack(Blocks.glass), "blockGlassColorless"); replacements.put(new ItemStack(Blocks.chest), "chestWood"); replacements.put(new ItemStack(Blocks.ender_chest), "chestEnder"); replacements.put(new ItemStack(Blocks.trapped_chest), "chestTrapped"); // Register dyes String[] dyes = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; for (int i = 0; i < 16; i++) { ItemStack dye = new ItemStack(Items.dye, 1, i); ItemStack block = new ItemStack(Blocks.stained_glass, 1, 15 - i); ItemStack pane = new ItemStack(Blocks.stained_glass_pane, 1, 15 - i); if (!hasInit) { registerOre("dye" + dyes[i], dye); registerOre("blockGlass" + dyes[i], block); registerOre("paneGlass" + dyes[i], pane); } replacements.put(dye, "dye" + dyes[i]); replacements.put(block, "blockGlass" + dyes[i]); replacements.put(pane, "paneGlass" + dyes[i]); } hasInit = true; ItemStack[] replaceStacks = replacements.keySet().toArray(new ItemStack[replacements.keySet().size()]); // Ignore recipes for the following items ItemStack[] exclusions = new ItemStack[] { new ItemStack(Blocks.lapis_block), new ItemStack(Items.cookie), new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stone_slab, 1, WILDCARD_VALUE), new ItemStack(Blocks.stone_stairs), new ItemStack(Blocks.cobblestone_wall), new ItemStack(Blocks.oak_fence), new ItemStack(Blocks.oak_fence_gate), new ItemStack(Blocks.oak_stairs), new ItemStack(Blocks.spruce_fence), new ItemStack(Blocks.spruce_fence_gate), new ItemStack(Blocks.spruce_stairs), new ItemStack(Blocks.birch_fence), new ItemStack(Blocks.birch_fence_gate), new ItemStack(Blocks.birch_stairs), new ItemStack(Blocks.jungle_fence), new ItemStack(Blocks.jungle_fence_gate), new ItemStack(Blocks.jungle_stairs), new ItemStack(Blocks.acacia_fence), new ItemStack(Blocks.acacia_fence_gate), new ItemStack(Blocks.acacia_stairs), new ItemStack(Blocks.dark_oak_fence), new ItemStack(Blocks.dark_oak_fence_gate), new ItemStack(Blocks.dark_oak_stairs), new ItemStack(Blocks.wooden_slab), new ItemStack(Blocks.glass_pane), null // So the above can have a comma and we don't have to keep editing extra lines. }; List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> recipesToRemove = new ArrayList<IRecipe>(); List<IRecipe> recipesToAdd = new ArrayList<IRecipe>(); // Search vanilla recipes for recipes to replace for (Object obj : recipes) { if (obj instanceof ShapedRecipes) { ShapedRecipes recipe = (ShapedRecipes) obj; ItemStack output = recipe.getRecipeOutput(); if (output != null && containsMatch(false, exclusions, output)) { continue; } if (containsMatch(true, recipe.recipeItems, replaceStacks)) { recipesToRemove.add(recipe); recipesToAdd.add(new ShapedOreRecipe(recipe, replacements)); } } else if (obj instanceof ShapelessRecipes) { ShapelessRecipes recipe = (ShapelessRecipes) obj; ItemStack output = recipe.getRecipeOutput(); if (output != null && containsMatch(false, exclusions, output)) { continue; } if (containsMatch( true, (ItemStack[]) recipe.recipeItems.toArray(new ItemStack[recipe.recipeItems.size()]), replaceStacks)) { recipesToRemove.add((IRecipe) obj); IRecipe newRecipe = new ShapelessOreRecipe(recipe, replacements); recipesToAdd.add(newRecipe); } } } recipes.removeAll(recipesToRemove); recipes.addAll(recipesToAdd); if (recipesToRemove.size() > 0) { FMLLog.info("Replaced %d ore recipies", recipesToRemove.size()); } }
public BukkitRecipe(ShapelessRecipes shapeless) { this.result = new CraftItemStack(shapeless.getRecipeOutput()); }
private static void initVanillaEntries() { if (!hasInit) { // tree- and wood-related things registerOre("logWood", new ItemStack(Blocks.log, 1, WILDCARD_VALUE)); registerOre("logWood", new ItemStack(Blocks.log2, 1, WILDCARD_VALUE)); registerOre("plankWood", new ItemStack(Blocks.planks, 1, WILDCARD_VALUE)); registerOre("slabWood", new ItemStack(Blocks.wooden_slab, 1, WILDCARD_VALUE)); registerOre("stairWood", Blocks.oak_stairs); registerOre("stairWood", Blocks.spruce_stairs); registerOre("stairWood", Blocks.birch_stairs); registerOre("stairWood", Blocks.jungle_stairs); registerOre("stairWood", Blocks.acacia_stairs); registerOre("stairWood", Blocks.dark_oak_stairs); registerOre("stickWood", Items.stick); registerOre("treeSapling", new ItemStack(Blocks.sapling, 1, WILDCARD_VALUE)); registerOre("treeLeaves", new ItemStack(Blocks.leaves, 1, WILDCARD_VALUE)); registerOre("treeLeaves", new ItemStack(Blocks.leaves2, 1, WILDCARD_VALUE)); registerOre("vine", Blocks.vine); // Ores registerOre("oreGold", Blocks.gold_ore); registerOre("oreIron", Blocks.iron_ore); registerOre("oreLapis", Blocks.lapis_ore); registerOre("oreDiamond", Blocks.diamond_ore); registerOre("oreRedstone", Blocks.redstone_ore); registerOre("oreEmerald", Blocks.emerald_ore); registerOre("oreQuartz", Blocks.quartz_ore); registerOre("oreCoal", Blocks.coal_ore); // ingots/nuggets registerOre("ingotIron", Items.iron_ingot); registerOre("ingotGold", Items.gold_ingot); registerOre("ingotBrick", Items.brick); registerOre("ingotBrickNether", Items.netherbrick); registerOre("nuggetGold", Items.gold_nugget); // gems and dusts registerOre("gemDiamond", Items.diamond); registerOre("gemEmerald", Items.emerald); registerOre("gemQuartz", Items.quartz); registerOre("gemPrismarine", Items.prismarine_shard); registerOre("dustPrismarine", Items.prismarine_crystals); registerOre("dustRedstone", Items.redstone); registerOre("dustGlowstone", Items.glowstone_dust); registerOre("gemLapis", new ItemStack(Items.dye, 1, 4)); // storage blocks registerOre("blockGold", Blocks.gold_block); registerOre("blockIron", Blocks.iron_block); registerOre("blockLapis", Blocks.lapis_block); registerOre("blockDiamond", Blocks.diamond_block); registerOre("blockRedstone", Blocks.redstone_block); registerOre("blockEmerald", Blocks.emerald_block); registerOre("blockQuartz", Blocks.quartz_block); registerOre("blockCoal", Blocks.coal_block); // crops registerOre("cropWheat", Items.wheat); registerOre("cropPotato", Items.potato); registerOre("cropCarrot", Items.carrot); registerOre("cropNetherWart", Items.nether_wart); registerOre("sugarcane", Items.reeds); registerOre("blockCactus", Blocks.cactus); // misc materials registerOre("dye", new ItemStack(Items.dye, 1, WILDCARD_VALUE)); registerOre("paper", new ItemStack(Items.paper)); // mob drops registerOre("slimeball", Items.slime_ball); registerOre("enderpearl", Items.ender_pearl); registerOre("bone", Items.bone); registerOre("gunpowder", Items.gunpowder); registerOre("string", Items.string); registerOre("netherStar", Items.nether_star); registerOre("leather", Items.leather); registerOre("feather", Items.feather); registerOre("egg", Items.egg); // records registerOre("record", Items.record_13); registerOre("record", Items.record_cat); registerOre("record", Items.record_blocks); registerOre("record", Items.record_chirp); registerOre("record", Items.record_far); registerOre("record", Items.record_mall); registerOre("record", Items.record_mellohi); registerOre("record", Items.record_stal); registerOre("record", Items.record_strad); registerOre("record", Items.record_ward); registerOre("record", Items.record_11); registerOre("record", Items.record_wait); // blocks registerOre("dirt", Blocks.dirt); registerOre("grass", Blocks.grass); registerOre("stone", Blocks.stone); registerOre("cobblestone", Blocks.cobblestone); registerOre("gravel", Blocks.gravel); registerOre("sand", new ItemStack(Blocks.sand, 1, WILDCARD_VALUE)); registerOre("sandstone", new ItemStack(Blocks.sandstone, 1, WILDCARD_VALUE)); registerOre("sandstone", new ItemStack(Blocks.red_sandstone, 1, WILDCARD_VALUE)); registerOre("netherrack", Blocks.netherrack); registerOre("obsidian", Blocks.obsidian); registerOre("glowstone", Blocks.glowstone); registerOre("endstone", Blocks.end_stone); registerOre("torch", Blocks.torch); registerOre("workbench", Blocks.crafting_table); registerOre("blockSlime", Blocks.slime_block); registerOre( "blockPrismarine", new ItemStack(Blocks.prismarine, 1, BlockPrismarine.EnumType.ROUGH.getMetadata())); registerOre( "blockPrismarineBrick", new ItemStack(Blocks.prismarine, 1, BlockPrismarine.EnumType.BRICKS.getMetadata())); registerOre( "blockPrismarineDark", new ItemStack(Blocks.prismarine, 1, BlockPrismarine.EnumType.DARK.getMetadata())); registerOre("stoneGranite", new ItemStack(Blocks.stone, 1, 1)); registerOre("stoneGranitePolished", new ItemStack(Blocks.stone, 1, 2)); registerOre("stoneDiorite", new ItemStack(Blocks.stone, 1, 3)); registerOre("stoneDioritePolished", new ItemStack(Blocks.stone, 1, 4)); registerOre("stoneAndesite", new ItemStack(Blocks.stone, 1, 5)); registerOre("stoneAndesitePolished", new ItemStack(Blocks.stone, 1, 6)); registerOre("blockGlassColorless", Blocks.glass); registerOre("blockGlass", Blocks.glass); registerOre("blockGlass", new ItemStack(Blocks.stained_glass, 1, WILDCARD_VALUE)); // blockGlass{Color} is added below with dyes registerOre("paneGlassColorless", Blocks.glass_pane); registerOre("paneGlass", Blocks.glass_pane); registerOre("paneGlass", new ItemStack(Blocks.stained_glass_pane, 1, WILDCARD_VALUE)); // paneGlass{Color} is added below with dyes // chests registerOre("chest", Blocks.chest); registerOre("chest", Blocks.ender_chest); registerOre("chest", Blocks.trapped_chest); registerOre("chestWood", Blocks.chest); registerOre("chestEnder", Blocks.ender_chest); registerOre("chestTrapped", Blocks.trapped_chest); } // Build our list of items to replace with ore tags Map<ItemStack, String> replacements = new HashMap<ItemStack, String>(); // wood-related things replacements.put(new ItemStack(Items.stick), "stickWood"); replacements.put(new ItemStack(Blocks.planks), "plankWood"); replacements.put(new ItemStack(Blocks.planks, 1, WILDCARD_VALUE), "plankWood"); replacements.put(new ItemStack(Blocks.wooden_slab, 1, WILDCARD_VALUE), "slabWood"); // ingots/nuggets replacements.put(new ItemStack(Items.gold_ingot), "ingotGold"); replacements.put(new ItemStack(Items.iron_ingot), "ingotIron"); // gems and dusts replacements.put(new ItemStack(Items.diamond), "gemDiamond"); replacements.put(new ItemStack(Items.emerald), "gemEmerald"); replacements.put(new ItemStack(Items.prismarine_shard), "gemPrismarine"); replacements.put(new ItemStack(Items.prismarine_crystals), "dustPrismarine"); replacements.put(new ItemStack(Items.redstone), "dustRedstone"); replacements.put(new ItemStack(Items.glowstone_dust), "dustGlowstone"); // crops replacements.put(new ItemStack(Items.reeds), "sugarcane"); replacements.put(new ItemStack(Blocks.cactus), "blockCactus"); // misc materials replacements.put(new ItemStack(Items.paper), "paper"); // mob drops replacements.put(new ItemStack(Items.slime_ball), "slimeball"); replacements.put(new ItemStack(Items.string), "string"); replacements.put(new ItemStack(Items.leather), "leather"); replacements.put(new ItemStack(Items.ender_pearl), "enderpearl"); replacements.put(new ItemStack(Items.gunpowder), "gunpowder"); replacements.put(new ItemStack(Items.nether_star), "netherStar"); replacements.put(new ItemStack(Items.feather), "feather"); replacements.put(new ItemStack(Items.bone), "bone"); replacements.put(new ItemStack(Items.egg), "egg"); // blocks replacements.put(new ItemStack(Blocks.stone), "stone"); replacements.put(new ItemStack(Blocks.cobblestone), "cobblestone"); replacements.put(new ItemStack(Blocks.cobblestone, 1, WILDCARD_VALUE), "cobblestone"); replacements.put(new ItemStack(Blocks.glowstone), "glowstone"); replacements.put(new ItemStack(Blocks.glass), "blockGlassColorless"); replacements.put(new ItemStack(Blocks.prismarine), "prismarine"); replacements.put(new ItemStack(Blocks.stone, 1, 1), "stoneGranite"); replacements.put(new ItemStack(Blocks.stone, 1, 2), "stoneGranitePolished"); replacements.put(new ItemStack(Blocks.stone, 1, 3), "stoneDiorite"); replacements.put(new ItemStack(Blocks.stone, 1, 4), "stoneDioritePolished"); replacements.put(new ItemStack(Blocks.stone, 1, 5), "stoneAndesite"); replacements.put(new ItemStack(Blocks.stone, 1, 6), "stoneAndesitePolished"); // chests replacements.put(new ItemStack(Blocks.chest), "chestWood"); replacements.put(new ItemStack(Blocks.ender_chest), "chestEnder"); replacements.put(new ItemStack(Blocks.trapped_chest), "chestTrapped"); // Register dyes String[] dyes = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; for (int i = 0; i < 16; i++) { ItemStack dye = new ItemStack(Items.dye, 1, i); ItemStack block = new ItemStack(Blocks.stained_glass, 1, 15 - i); ItemStack pane = new ItemStack(Blocks.stained_glass_pane, 1, 15 - i); if (!hasInit) { registerOre("dye" + dyes[i], dye); registerOre("blockGlass" + dyes[i], block); registerOre("paneGlass" + dyes[i], pane); } replacements.put(dye, "dye" + dyes[i]); replacements.put(block, "blockGlass" + dyes[i]); replacements.put(pane, "paneGlass" + dyes[i]); } hasInit = true; ItemStack[] replaceStacks = replacements.keySet().toArray(new ItemStack[replacements.keySet().size()]); // Ignore recipes for the following items ItemStack[] exclusions = new ItemStack[] { new ItemStack(Blocks.lapis_block), new ItemStack(Items.cookie), new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stone_slab, 1, WILDCARD_VALUE), new ItemStack(Blocks.stone_stairs), new ItemStack(Blocks.cobblestone_wall), new ItemStack(Blocks.oak_fence), new ItemStack(Blocks.oak_fence_gate), new ItemStack(Blocks.oak_stairs), new ItemStack(Blocks.spruce_fence), new ItemStack(Blocks.spruce_fence_gate), new ItemStack(Blocks.spruce_stairs), new ItemStack(Blocks.birch_fence), new ItemStack(Blocks.birch_fence_gate), new ItemStack(Blocks.birch_stairs), new ItemStack(Blocks.jungle_fence), new ItemStack(Blocks.jungle_fence_gate), new ItemStack(Blocks.jungle_stairs), new ItemStack(Blocks.acacia_fence), new ItemStack(Blocks.acacia_fence_gate), new ItemStack(Blocks.acacia_stairs), new ItemStack(Blocks.dark_oak_fence), new ItemStack(Blocks.dark_oak_fence_gate), new ItemStack(Blocks.dark_oak_stairs), new ItemStack(Blocks.wooden_slab), new ItemStack(Blocks.glass_pane), null // So the above can have a comma and we don't have to keep editing extra lines. }; List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> recipesToRemove = new ArrayList<IRecipe>(); List<IRecipe> recipesToAdd = new ArrayList<IRecipe>(); // Search vanilla recipes for recipes to replace for (Object obj : recipes) { if (obj instanceof ShapedRecipes) { ShapedRecipes recipe = (ShapedRecipes) obj; ItemStack output = recipe.getRecipeOutput(); if (output != null && containsMatch(false, exclusions, output)) { continue; } if (containsMatch(true, recipe.recipeItems, replaceStacks)) { recipesToRemove.add(recipe); recipesToAdd.add(new ShapedOreRecipe(recipe, replacements)); } } else if (obj instanceof ShapelessRecipes) { ShapelessRecipes recipe = (ShapelessRecipes) obj; ItemStack output = recipe.getRecipeOutput(); if (output != null && containsMatch(false, exclusions, output)) { continue; } if (containsMatch( true, recipe.recipeItems.toArray(new ItemStack[recipe.recipeItems.size()]), replaceStacks)) { recipesToRemove.add((IRecipe) obj); IRecipe newRecipe = new ShapelessOreRecipe(recipe, replacements); recipesToAdd.add(newRecipe); } } } recipes.removeAll(recipesToRemove); recipes.addAll(recipesToAdd); if (recipesToRemove.size() > 0) { FMLLog.info("Replaced %d ore recipes", recipesToRemove.size()); } }