123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- package me.km.items;
- import me.km.blocks.EnumMetals;
- import me.km.blocks.ModBlocks;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.init.Items;
- import net.minecraft.item.EnumDyeColor;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.CraftingManager;
- import net.minecraft.item.crafting.FurnaceRecipes;
- public class ModRecipes
- {
- public static void init()
- {
- CraftingManager cm = CraftingManager.getInstance();
- FurnaceRecipes fr = FurnaceRecipes.instance();
- // misc
- cm.addShapelessRecipe(new ItemStack(ModItems.bronzeIngot, 9), new Object[]
- {
- ModItems.copperIngot, ModItems.copperIngot, ModItems.copperIngot,
- ModItems.copperIngot, ModItems.copperIngot, ModItems.copperIngot,
- ModItems.copperIngot, ModItems.copperIngot, ModItems.tinIngot
- });
- cm.addRecipe(new ItemStack(ModItems.realHayBed, 3), new Object[] {"XXX", 'X', ModBlocks.realHayBlock});
- cm.addRecipe(new ItemStack(ModItems.strawHat, 1), new Object[] {" X ", "XXX", 'X', Items.WHEAT});
-
- // traps
- addMetalRecipes(cm, new String[] {" X ", "XXX"}, ModBlocks.spikes, 3);
-
- // furnace recipes
- fr.addSmeltingRecipeForBlock(ModBlocks.copperOre, new ItemStack(ModItems.copperIngot), 0.5f);
- fr.addSmeltingRecipeForBlock(ModBlocks.tinOre, new ItemStack(ModItems.tinIngot), 1);
- fr.addSmeltingRecipeForBlock(ModBlocks.silverOre, new ItemStack(ModItems.silverIngot), 1);
-
- // armor recipes
- Item[][] armorItems = new Item[][]
- {
- {ModItems.copperIngot, ModItems.bronzeIngot},
- {ModItems.copperHelmet, ModItems.bronzeHelmet},
- {ModItems.copperChestplate, ModItems.bronzeChestplate},
- {ModItems.copperLeggings, ModItems.bronzeLeggings},
- {ModItems.copperBoots, ModItems.bronzeBoots}
- };
- addArmorRecipes(cm, armorItems);
-
- // additionel old tool recipes
- String[][] toolPatterns = new String[][] {{"XXX", " # ", " # "}, {"X", "#", "#"}, {"XX", "X#", " #"}, {"XX", " #", " #"}};
- Object[][] toolItems = new Object[][]
- {
- {ModItems.copperIngot, ModItems.bronzeIngot},
- {ModItems.copperPickaxe, ModItems.bronzePickaxe},
- {ModItems.copperShovel, ModItems.bronzeShovel},
- {ModItems.copperAxe, ModItems.bronzeAxe},
- {ModItems.copperHoe, ModItems.bronzeHoe}
- };
- addToolRecipes(cm, toolPatterns, toolItems);
-
- // new tool / weapon recipes
- toolPatterns = new String[][] {{"X ", " # ", " X"}, {" X", "# "}, {"XXX", "X#X", " # "}};
- toolItems = new Object[][]
- {
- {Blocks.PLANKS, Blocks.COBBLESTONE, Items.IRON_INGOT, Items.DIAMOND,
- Items.GOLD_INGOT, ModItems.copperIngot, ModItems.bronzeIngot},
- {ModItems.woodenStick, ModItems.stoneStick, ModItems.ironStick, ModItems.diamondStick,
- ModItems.goldStick, ModItems.copperStick, ModItems.bronzeStick},
- {ModItems.woodenDagger, ModItems.stoneDagger, ModItems.ironDagger, ModItems.diamondDagger,
- ModItems.goldDagger, ModItems.copperDagger, ModItems.bronzeDagger},
- {ModItems.woodenHammer, ModItems.stoneHammer, ModItems.ironHammer, ModItems.diamondHammer,
- ModItems.goldHammer, ModItems.copperHammer, ModItems.bronzeHammer},
- };
- addToolRecipes(cm, toolPatterns, toolItems);
-
- // wands
- toolPatterns = new String[][] {{" #X", " ##", "# "}};
- toolItems = new Object[][]
- {
- {Blocks.PLANKS, Blocks.COBBLESTONE, Items.IRON_INGOT, Items.DIAMOND, Items.GOLD_INGOT,
- ModItems.copperIngot, ModItems.bronzeIngot, Items.EMERALD, Items.REDSTONE,
- new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()), ModItems.silverIngot},
- {ModItems.woodenWand, ModItems.stoneWand, ModItems.ironWand, ModItems.diamondWand, ModItems.goldWand,
- ModItems.copperWand, ModItems.bronzeWand, ModItems.emeraldWand, ModItems.redstoneWand,
- ModItems.lapisWand, ModItems.silverWand},
- };
- addToolRecipes(cm, toolPatterns, toolItems);
-
- // additionel old weapon recipes
- Object[][] weaponItems = new Object[][]
- {
- {ModItems.copperIngot, ModItems.bronzeIngot},
- {ModItems.copperSword, ModItems.bronzeSword}
- };
- addWeaponRecipes(cm, weaponItems);
-
- // block <-> parts <-> smaller parts recipes
- Object[][] ingotItems = new Object[][]
- {
- {ModBlocks.copperBlock, new ItemStack(ModItems.copperIngot, 9)},
- {ModItems.copperIngot, new ItemStack(ModItems.copperNugget, 9)},
- {ModBlocks.tinBlock, new ItemStack(ModItems.tinIngot, 9)},
- {ModItems.tinIngot, new ItemStack(ModItems.tinNugget, 9)},
- {ModBlocks.bronzeBlock, new ItemStack(ModItems.bronzeIngot, 9)},
- {ModItems.bronzeIngot, new ItemStack(ModItems.bronzeNugget, 9)},
- {ModBlocks.silverBlock, new ItemStack(ModItems.silverIngot, 9)},
- {ModItems.silverIngot, new ItemStack(ModItems.silverNugget, 9)},
- {ModBlocks.realHayBlock, new ItemStack(ModItems.hayBundle, 9)},
- };
- addIngotRecipes(cm, ingotItems);
- addNuggetRecipes(fr, toolItems, armorItems, weaponItems, ModItems.copperNugget, ModItems.bronzeNugget);
- }
- private static void addArmorRecipes(CraftingManager cm, Item[][] armorItems)
- {
- String[][] armorPatterns = new String[][] {{"XXX", "X X"}, {"X X", "XXX", "XXX"}, {"XXX", "X X", "X X"}, {"X X", "X X"}};
- for (int i = 0; i < armorItems[0].length; ++i)
- {
- Item item = armorItems[0][i];
- for (int j = 0; j < armorItems.length - 1; ++j)
- {
- Item item2 = armorItems[j + 1][i];
- cm.addRecipe(new ItemStack(item2), new Object[] {armorPatterns[j], 'X', item});
- }
- }
- }
-
- private static void addToolRecipes(CraftingManager cm, String[][] toolPatterns, Object[][] toolItems)
- {
- for(int i = 0; i < toolItems[0].length; ++i)
- {
- Object object = toolItems[0][i];
- for(int j = 0; j < toolItems.length - 1; ++j)
- {
- Item item = (Item) toolItems[j + 1][i];
- cm.addRecipe(new ItemStack(item), new Object[] {toolPatterns[j], '#', Items.STICK, 'X', object});
- }
- }
- }
-
- private static void addWeaponRecipes(CraftingManager cm, Object[][] weaponItems)
- {
- String[][] weaponPatterns = new String[][] {{"X", "X", "#"}};
- for(int i = 0; i < weaponItems[0].length; ++i)
- {
- Object object = weaponItems[0][i];
- for(int j = 0; j < weaponItems.length - 1; ++j)
- {
- Item item = (Item) weaponItems[j + 1][i];
- cm.addRecipe(new ItemStack(item), new Object[] {weaponPatterns[j], '#', Items.STICK, 'X', object});
- }
- }
- }
- private static void addIngotRecipes(CraftingManager cm, Object[][] ingotItems)
- {
- for(Object[] aobject : ingotItems)
- {
- try
- {
- Item block = (Item) aobject[0];
- ItemStack parts = (ItemStack) aobject[1];
- ItemStack ingot = parts.copy();
- ingot.setCount(1);
- cm.addRecipe(new ItemStack(block), new Object[] {"###", "###", "###", '#', ingot});
- cm.addRecipe(parts, new Object[] {"#", '#', block});
- }
- catch(ClassCastException ex)
- {
- Block block = (Block) aobject[0];
- ItemStack parts = (ItemStack) aobject[1];
- ItemStack ingot = parts.copy();
- ingot.setCount(1);
- cm.addRecipe(new ItemStack(block), new Object[] {"###", "###", "###", '#', ingot});
- cm.addRecipe(parts, new Object[] {"#", '#', block});
- }
- }
- }
-
- private static void addNuggetRecipes(FurnaceRecipes fr, Object[][] toolItems, Item[][] armorItems, Object[][] weaponItems, Item... nuggets)
- {
- for(int i = 0; i < nuggets.length; i++)
- {
- for(int j = 1; j < toolItems.length; j++)
- {
- fr.addSmelting((Item) toolItems[j][i], new ItemStack(nuggets[i]), 0.1f);
- }
- for(int j = 1; j < armorItems.length; j++)
- {
- fr.addSmelting((Item) armorItems[j][i], new ItemStack(nuggets[i]), 0.1f);
- }
- for(int j = 1; j < weaponItems.length; j++)
- {
- fr.addSmelting((Item) weaponItems[j][i], new ItemStack(nuggets[i]), 0.1f);
- }
- }
- }
-
- private static void addMetalRecipes(CraftingManager cm, String[] patterns, Item output, int amount)
- {
- for(EnumMetals metal : EnumMetals.values())
- {
- cm.addRecipe(new ItemStack(output, amount, metal.getMetadata()),
- new Object[] {patterns, 'X', metal.getMetalIngot()});
- }
- }
-
- private static void addMetalRecipes(CraftingManager cm, String[] patterns, Block output, int amount)
- {
- addMetalRecipes(cm, patterns, Item.getItemFromBlock(output), amount);
- }
- }
|