From 1fe751f5479ffd3c071bfba86766d2a6235337d6 Mon Sep 17 00:00:00 2001 From: Robert S Date: Tue, 22 Jul 2014 15:55:09 -0400 Subject: [PATCH] Changed crate crafting to use a recipe instead of handler object --- .../archaic/crate/CrateCraftingHandler.java | 41 ----------------- .../archaic/crate/CrateRecipe.java | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 41 deletions(-) delete mode 100644 src/main/scala/resonantinduction/archaic/crate/CrateCraftingHandler.java create mode 100644 src/main/scala/resonantinduction/archaic/crate/CrateRecipe.java diff --git a/src/main/scala/resonantinduction/archaic/crate/CrateCraftingHandler.java b/src/main/scala/resonantinduction/archaic/crate/CrateCraftingHandler.java deleted file mode 100644 index e361b4340..000000000 --- a/src/main/scala/resonantinduction/archaic/crate/CrateCraftingHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package resonantinduction.archaic.crate; - -import resonantinduction.archaic.Archaic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import resonantinduction.archaic.Archaic; -import cpw.mods.fml.common.ICraftingHandler; -import resonantinduction.archaic.Archaic; - -/** Crafting handler for crates - * - * @author Darkguardsman */ -public class CrateCraftingHandler implements ICraftingHandler -{ - @Override - public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) - { - if (item != null && item.itemID == Archaic.blockCrate.blockID) - { - ItemStack centerStack = craftMatrix.getStackInSlot(4); - if (centerStack != null && centerStack.itemID == Archaic.blockCrate.blockID) - { - ItemStack containedStack = ItemBlockCrate.getContainingItemStack(centerStack); - if (centerStack != null) - { - ItemBlockCrate.setContainingItemStack(item, containedStack); - } - } - } - - } - - @Override - public void onSmelting(EntityPlayer player, ItemStack item) - { - // TODO Auto-generated method stub - - } - -} diff --git a/src/main/scala/resonantinduction/archaic/crate/CrateRecipe.java b/src/main/scala/resonantinduction/archaic/crate/CrateRecipe.java new file mode 100644 index 000000000..b6e4ee40c --- /dev/null +++ b/src/main/scala/resonantinduction/archaic/crate/CrateRecipe.java @@ -0,0 +1,44 @@ +package resonantinduction.archaic.crate; + +import net.minecraft.block.Block; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; +import resonantinduction.archaic.Archaic; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import resonantinduction.archaic.ArchaicBlocks; +import net.minecraftforge.oredict.ShapedOreRecipe; + +/** Crafting handler for crates + * + * @author Darkguardsman */ +public class CrateRecipe extends ShapedOreRecipe implements IRecipe +{ + public CrateRecipe(Block result, Object... recipe){ super(new ItemStack(result), recipe); } + public CrateRecipe(Item result, Object... recipe){ super(new ItemStack(result), recipe); } + public CrateRecipe(ItemStack result, Object... recipe){super(result, recipe);} + + @Override + public ItemStack getCraftingResult(InventoryCrafting grid) + { + ItemStack result = super.getCraftingResult(grid); + Item crateItem = Item.getItemFromBlock(ArchaicBlocks.blockCrate()); + + if (result != null && result.getItem() == crateItem ) + { + ItemStack centerStack = grid.getStackInSlot(4); + if (centerStack != null && centerStack.getItem() == crateItem ) + { + ItemStack containedStack = ItemBlockCrate.getContainingItemStack(centerStack); + if (centerStack != null) + { + ItemBlockCrate.setContainingItemStack(result, containedStack); + } + } + } + return result; + } +}