Changed crate crafting to use a recipe instead of handler object
This commit is contained in:
parent
a20db4091b
commit
1fe751f547
2 changed files with 44 additions and 41 deletions
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue