From b1fcb1ab3eb1cf5cc55134cb6863e01a4c84eb6b Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Thu, 25 Jun 2015 00:37:32 -0400 Subject: [PATCH] Use ore dictionary key to work around recipe combinatorics and easily support addon packs. --- .../storagedrawers/core/ModBlocks.java | 13 +++++++++ .../storagedrawers/core/ModRecipes.java | 29 +++++-------------- .../storagedrawers/core/api/PackFactory.java | 6 +++- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java index 5c95a3409..6b42b5274 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java @@ -14,6 +14,8 @@ import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class ModBlocks { @@ -71,6 +73,17 @@ public void init () { GameRegistry.registerTileEntityWithAlternatives(TileEntitySlave.class, getQualifiedName("tileControllerSlave"), getQualifiedName(controllerSlave)); + + for (String key : new String[] { "drawerBasic" }) + OreDictionary.registerOre(key, new ItemStack(fullDrawers1, 1, OreDictionary.WILDCARD_VALUE)); + for (String key : new String[] { "drawerBasic" }) + OreDictionary.registerOre(key, new ItemStack(fullDrawers2, 1, OreDictionary.WILDCARD_VALUE)); + for (String key : new String[] { "drawerBasic" }) + OreDictionary.registerOre(key, new ItemStack(fullDrawers4, 1, OreDictionary.WILDCARD_VALUE)); + for (String key : new String[] { "drawerBasic" }) + OreDictionary.registerOre(key, new ItemStack(halfDrawers2, 1, OreDictionary.WILDCARD_VALUE)); + for (String key : new String[] { "drawerBasic" }) + OreDictionary.registerOre(key, new ItemStack(halfDrawers4, 1, OreDictionary.WILDCARD_VALUE)); } public static String getQualifiedName (String name) { diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java index c152e4f7a..1fa9b8338 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java @@ -60,32 +60,19 @@ public void init () { 'x', "stickWood", 'y', "plankWood")); if (config.isBlockEnabled("compdrawers")) - GameRegistry.addRecipe(new ItemStack(ModBlocks.compDrawers, config.getBlockRecipeOutput("compdrawers")), "xxx", "zwz", "xyx", - 'x', new ItemStack(Blocks.stone), 'y', Items.iron_ingot, 'z', new ItemStack(Blocks.piston), 'w', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE)); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.compDrawers, config.getBlockRecipeOutput("compdrawers")), "xxx", "zwz", "xyx", + 'x', new ItemStack(Blocks.stone), 'y', Items.iron_ingot, 'z', new ItemStack(Blocks.piston), 'w', "drawerBasic")); if (config.isBlockEnabled("controller")) - GameRegistry.addRecipe(new ItemStack(ModBlocks.controller), "xxx", "yzy", "xwx", - 'x', new ItemStack(Blocks.stone), 'y', Items.comparator, 'z', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE), 'w', Items.diamond); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.controller), "xxx", "yzy", "xwx", + 'x', new ItemStack(Blocks.stone), 'y', Items.comparator, 'z', "drawerBasic", 'w', Items.diamond)); if (config.isBlockEnabled("controllerSlave")) - GameRegistry.addRecipe(new ItemStack(ModBlocks.controllerSlave), "xxx", "yzy", "xwx", - 'x', new ItemStack(Blocks.stone), 'y', Items.comparator, 'z', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE), 'w', Items.gold_ingot); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.controllerSlave), "xxx", "yzy", "xwx", + 'x', new ItemStack(Blocks.stone), 'y', Items.comparator, 'z', "drawerBasic", 'w', Items.gold_ingot)); - if (config.isBlockEnabled("fulldrawers1")) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx", - 'x', "stickWood", 'y', new ItemStack(ModBlocks.fullDrawers1, 1, OreDictionary.WILDCARD_VALUE))); - if (config.isBlockEnabled("fulldrawers2")) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx", - 'x', "stickWood", 'y', new ItemStack(ModBlocks.fullDrawers2, 1, OreDictionary.WILDCARD_VALUE))); - if (config.isBlockEnabled("halfdrawers2")) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx", - 'x', "stickWood", 'y', new ItemStack(ModBlocks.halfDrawers2, 1, OreDictionary.WILDCARD_VALUE))); - if (config.isBlockEnabled("fulldrawers4")) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx", - 'x', "stickWood", 'y', new ItemStack(ModBlocks.fullDrawers4, 1, OreDictionary.WILDCARD_VALUE))); - if (config.isBlockEnabled("halfdrawers4")) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx", - 'x', "stickWood", 'y', new ItemStack(ModBlocks.halfDrawers4, 1, OreDictionary.WILDCARD_VALUE))); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgradeTemplate, 2), "xxx", "xyx", "xxx", + 'x', "stickWood", 'y', "drawerBasic")); if (config.cache.enableStorageUpgrades) { GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.upgrade, 1, 2), "xyx", "yzy", "xyx", diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java b/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java index 27af86de0..da00a13a1 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java @@ -14,6 +14,8 @@ import com.jaquadro.minecraft.storagedrawers.item.pack.ItemTrimPack; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class PackFactory implements IPackBlockFactory { @@ -35,8 +37,10 @@ public Block createBlock (BlockConfiguration blockConfig, IPackDataResolver data @Override public void registerBlock (Block block, String name) { - if (block instanceof BlockDrawersPack) + if (block instanceof BlockDrawersPack) { GameRegistry.registerBlock(block, ItemDrawersPack.class, name); + OreDictionary.registerOre("drawerBasic", new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE)); + } else if (block instanceof BlockSortingDrawersPack) GameRegistry.registerBlock(block, ItemSortingDrawersPack.class, name); else if (block instanceof BlockTrimPack)