aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/core/block/ModBlocks.java26
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java77
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_Workbench.java205
-rw-r--r--src/Java/gtPlusPlus/core/gui/machine/GUI_Workbench.java41
-rw-r--r--src/Java/gtPlusPlus/core/handler/GuiHandler.java24
-rw-r--r--src/Java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java213
-rw-r--r--src/Java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java43
-rw-r--r--src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java183
-rw-r--r--src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java182
-rw-r--r--src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java184
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotCrafting.java164
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotGtTool.java25
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java3
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java52
-rw-r--r--src/Java/gtPlusPlus/core/util/Utils.java7
15 files changed, 1406 insertions, 23 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java
index de4520fee9..e8334af98b 100644
--- a/src/Java/gtPlusPlus/core/block/ModBlocks.java
+++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java
@@ -1,6 +1,7 @@
package gtPlusPlus.core.block;
import gtPlusPlus.core.block.general.LightGlass;
+import gtPlusPlus.core.block.machine.Machine_Workbench;
import gtPlusPlus.core.fluids.FluidRegistryHandler;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
@@ -12,6 +13,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
public final class ModBlocks {
+ public static Block blockWorkbench;
//Blocks
//public static Block blockBloodSteel;
//public static Block blockStaballoy;
@@ -39,15 +41,6 @@ public final class ModBlocks {
public static void registerBlocks(){
Utils.LOG_INFO("Registering Blocks.");
-
- //Blood Steel Block
- //GameRegistry.registerBlock(blockBloodSteel = new BasicBlock("blockBloodSteel", Material.iron), "blockBloodSteel");
-
- //Staballoy Block
- //GameRegistry.registerBlock(blockStaballoy = new BasicBlock("blockStaballoy", Material.iron), "blockStaballoy");
-
- //GameRegistry.registerBlock(MatterFabricatorEffectBlock = new MatterFabricatorEffectBlock(), "blockMF_Effect");
-
GameRegistry.registerBlock(MatterFabricatorEffectBlock = new LightGlass(Material.glass, false).setHardness(0.1F).setBlockTextureName(CORE.MODID + ":" + "blockMFEffect").setStepSound(Block.soundTypeGlass), "blockMFEffect");
@@ -57,19 +50,10 @@ public final class ModBlocks {
//Fluids
FluidRegistryHandler.registerFluids();
- // blockHeliumGenerator = GameRegistry.registerBlock(new HeliumGenerator(), "Helium_Collector");
- // blockNHG = GameRegistry.registerBlock(new Machine_NHG("blockNuclearFueledHeliumGenerator"), "blockNuclearFueledHeliumGenerator");
- // blockCharger = GameRegistry.registerBlock(new Machine_Charger("blockMachineCharger"), "blockMachineCharger");
-
-
- //WIP TODO
- //GameRegistry.registerBlock(blockGriefSaver, "blockGriefSaver");
+ //Workbench
+ blockWorkbench = new Machine_Workbench().setHardness(1.5F);
- //GtFrames
- //GameRegistry.registerBlock(blockGtFrameSet1 = new BlockGtFrameBox("blockGtFrameSet1", Material.iron ,BlockTypes.FRAME, true, Utils.rgbtoHexValue(68, 75, 66), Utils.rgbtoHexValue(68, 75, 166), Utils.rgbtoHexValue(122, 135, 196)), "blockGtFrameSet1");
- //GameRegistry.registerBlock(blockGtFrameTantalloy60 = new BlockBaseModular("blockGtFrameStaballoy", "Staballoy", BlockTypes.FRAME, Utils.rgbtoHexValue(68, 75, 66)), ItemBlockGtFrameBox.class, "blockGtFrameStaballoy");
- //GameRegistry.registerBlock(blockGtFrameTantalloy60 = new BlockBaseModular("blockGtFrameTantalloy60", "Tantalloy-60", BlockTypes.FRAME, Utils.rgbtoHexValue(68, 75, 166)), ItemBlockGtFrameBox.class, "blockGtFrameTantalloy60");
- //GameRegistry.registerBlock(blockGtFrameTantalloy61 = new BlockBaseModular("blockGtFrameTantalloy61", "Tantalloy-61", BlockTypes.FRAME, Utils.rgbtoHexValue(122, 135, 196)), ItemBlockGtFrameBox.class, "blockGtFrameTantalloy61");
+
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java
new file mode 100644
index 0000000000..92ba4a11cc
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java
@@ -0,0 +1,77 @@
+package gtPlusPlus.core.block.machine;
+
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class Machine_Workbench extends BlockContainer
+{
+ @SideOnly(Side.CLIENT)
+ private IIcon textureTop;
+ @SideOnly(Side.CLIENT)
+ private IIcon textureFront;
+
+ public Machine_Workbench()
+ {
+ super(Material.iron);
+ this.setBlockName("blockWorkbenchGT");
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ GameRegistry.registerBlock(this, "blockWorkbenchGT");
+ LanguageRegistry.addName(this, "Gregtech Workbench");
+
+ }
+
+ /**
+ * Gets the block's texture. Args: side, meta
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int p_149691_1_, int p_149691_2_)
+ {
+ return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? Blocks.planks.getBlockTextureFromSide(p_149691_1_) : (p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.textureFront));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister p_149651_1_)
+ {
+ this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "workbench");
+ this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "workbench" + "_top");
+ this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "workbench");
+ }
+
+ /**
+ * Called upon block activation (right click on the block.)
+ */
+ @Override
+ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz)
+ {
+ if (world.isRemote) return true;
+
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null && te instanceof TileEntityWorkbench)
+ {
+ player.openGui(GTplusplus.instance, 3, world, x, y, z);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int p_149915_2_) {
+ return new TileEntityWorkbench();
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/container/Container_Workbench.java b/src/Java/gtPlusPlus/core/container/Container_Workbench.java
new file mode 100644
index 0000000000..09abd8e23a
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/container/Container_Workbench.java
@@ -0,0 +1,205 @@
+package gtPlusPlus.core.container;
+
+import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.handler.workbench.Workbench_CraftingHandler;
+import gtPlusPlus.core.inventories.InventoryWorkbenchChest;
+import gtPlusPlus.core.inventories.InventoryWorkbenchTools;
+import gtPlusPlus.core.slots.SlotGtTool;
+import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.InventoryCraftResult;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.inventory.SlotCrafting;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+public class Container_Workbench extends Container {
+
+ protected TileEntityWorkbench tile_entity;
+ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
+ public final InventoryWorkbenchChest inventoryChest;
+ public final InventoryWorkbenchTools inventoryTool;
+ public IInventory craftResult = new InventoryCraftResult();
+ private World worldObj;
+ private int posX;
+ private int posY;
+ private int posZ;
+
+ public static int StorageSlotNumber = 12; //Number of slots in storage area
+ public static int ToolSlotNumber = 5; // Number of slots in the tool area up top
+ public static int InputSlotNumber = 9; //Number of Slots in the Crafting Grid
+ public static int InOutputSlotNumber = InputSlotNumber + 1; //Same plus Output Slot
+ public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar)
+ public static int InventoryOutSlotNumber = InventorySlotNumber + 1; //Inventory Slot Number + Output
+ public static int FullSlotNumber = InventorySlotNumber + InOutputSlotNumber; //All slots
+
+
+
+ public Container_Workbench(InventoryPlayer inventory, TileEntityWorkbench tile){
+
+ this.tile_entity = tile;
+ this.inventoryChest = tile.inventoryChest;
+ this.inventoryTool = tile.inventoryTool;
+
+ int o=0;
+
+ int var6;
+ int var7;
+ worldObj = tile.getWorldObj();
+ posX = tile.xCoord;
+ posY = tile.yCoord;
+ posZ = tile.zCoord;
+
+ //Output slot
+ addSlotToContainer(new SlotCrafting(inventory.player, this.craftMatrix, craftResult, 0, 136, 64));
+
+ //Crafting Grid
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 3; ++var7)
+ {
+ this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 3, 82 + var7 * 18, 28 + var6 * 18));
+ }
+ }
+
+ //Storage Side
+ for (var6 = 0; var6 < 4; ++var6)
+ {
+ for (var7 = 0; var7 < 4; ++var7)
+ {
+ this.addSlotToContainer(new Slot(inventoryChest, var7 + var6 * 3, 8 + var7 * 18, 7 + var6 * 18));
+ }
+ }
+
+ //Tool Slots
+ for (var6 = 0; var6 < 1; ++var6)
+ {
+ for (var7 = 0; var7 < 5; ++var7)
+ {
+ this.addSlotToContainer(new SlotGtTool(inventoryTool, var7 + var6 * 3, 82 + var7 * 18, 8 + var6 * 18));
+ }
+ }
+
+ //Player Inventory
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 9; ++var7)
+ {
+ this.addSlotToContainer(new Slot(inventory, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18));
+ }
+ }
+
+ //Player Hotbar
+ for (var6 = 0; var6 < 9; ++var6)
+ {
+ this.addSlotToContainer(new Slot(inventory, var6, 8 + var6 * 18, 142));
+ }
+
+ this.onCraftMatrixChanged(this.craftMatrix);
+
+ }
+
+
+ @Override
+ public void onCraftMatrixChanged(IInventory par1IInventory){
+ craftResult.setInventorySlotContents(0, Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix, worldObj));
+ }
+
+
+ @Override
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+
+ super.onContainerClosed(par1EntityPlayer);
+
+ if (worldObj.isRemote)
+ {
+ return;
+ }
+
+ for (int i = 0; i < InputSlotNumber; i++)
+ {
+ ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
+
+ if (itemstack != null)
+ {
+ par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false);
+ }
+ }
+
+ }
+
+
+ @Override
+ public boolean canInteractWith(EntityPlayer par1EntityPlayer){
+ if (worldObj.getBlock(posX, posY, posZ) != ModBlocks.blockWorkbench){
+ return false;
+ }
+
+ return par1EntityPlayer.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64D;
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
+ {
+ ItemStack var3 = null;
+ Slot var4 = (Slot)this.inventorySlots.get(par2);
+
+ if (var4 != null && var4.getHasStack())
+ {
+ ItemStack var5 = var4.getStack();
+ var3 = var5.copy();
+
+ if (par2 == 0)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true))
+ {
+ return null;
+ }
+
+ var4.onSlotChange(var5, var3);
+ }
+ else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false))
+ {
+ return null;
+ }
+ }
+ else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false))
+ {
+ return null;
+ }
+ }
+ else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false))
+ {
+ return null;
+ }
+
+ if (var5.stackSize == 0)
+ {
+ var4.putStack((ItemStack)null);
+ }
+ else
+ {
+ var4.onSlotChanged();
+ }
+
+ if (var5.stackSize == var3.stackSize)
+ {
+ return null;
+ }
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+
+ return var3;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_Workbench.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_Workbench.java
new file mode 100644
index 0000000000..c1b6904cb4
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_Workbench.java
@@ -0,0 +1,41 @@
+package gtPlusPlus.core.gui.machine;
+
+import gtPlusPlus.core.container.Container_Workbench;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+@SideOnly(Side.CLIENT)
+public class GUI_Workbench extends GuiContainer {
+
+ private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/Workbench.png");
+
+ public GUI_Workbench(InventoryPlayer player_inventory, TileEntityWorkbench tile){
+ super(new Container_Workbench(player_inventory, tile));
+}
+
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int i, int j){
+ //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752);
+ //this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
+
+ }
+
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float f, int i, int j){
+ GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ this.mc.renderEngine.bindTexture(craftingTableGuiTextures);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
index 7c9c7a7625..b9b3229f13 100644
--- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
@@ -2,12 +2,15 @@ package gtPlusPlus.core.handler;
import gtPlusPlus.GTplusplus;
import gtPlusPlus.core.container.Container_BackpackBase;
+import gtPlusPlus.core.container.Container_Workbench;
import gtPlusPlus.core.gui.beta.Gui_ID_Registry;
import gtPlusPlus.core.gui.beta.MU_GuiId;
import gtPlusPlus.core.gui.item.GuiBaseBackpack;
+import gtPlusPlus.core.gui.machine.GUI_Workbench;
import gtPlusPlus.core.interfaces.IGuiManager;
import gtPlusPlus.core.inventories.BaseInventoryBackpack;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing;
import gtPlusPlus.xmod.forestry.bees.alveary.gui.CONTAINER_FrameHousing;
@@ -24,7 +27,7 @@ public class GuiHandler implements IGuiHandler {
public static final int GUI1 = 0; //Frame Alveary
public static final int GUI2 = 1; //RTG
public static final int GUI3 = 2; //BackpackHandler
- public static final int GUI4 = 3; //
+ public static final int GUI4 = 3; //Workbench
public static final int GUI5 = 4; //
public static final int GUI6 = 5; //
public static final int GUI7 = 6; //
@@ -63,6 +66,19 @@ public class GuiHandler implements IGuiHandler {
// Use the player's held item to create the inventory
return new Container_BackpackBase(player, player.inventory, new BaseInventoryBackpack(player.getHeldItem()));
}
+
+ if (te != null){
+ if (ID == GUI4){
+ return new Container_Workbench(player.inventory, (TileEntityWorkbench)te);
+ }
+ }
+
+
+
+
+
+
+
return null;
}
@@ -90,6 +106,12 @@ public class GuiHandler implements IGuiHandler {
return new GuiBaseBackpack((Container_BackpackBase) new Container_BackpackBase(player, player.inventory, new BaseInventoryBackpack(player.getHeldItem())));
}
+ if (te != null){
+ if (ID == GUI4){
+ return new GUI_Workbench(player.inventory, (TileEntityWorkbench)te);
+ }
+ }
+
return null;
}
diff --git a/src/Java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java b/src/Java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java
new file mode 100644
index 0000000000..b5c0c035ec
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java
@@ -0,0 +1,213 @@
+package gtPlusPlus.core.handler.workbench;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapedRecipes;
+import net.minecraft.item.crafting.ShapelessRecipes;
+import net.minecraft.world.World;
+
+public class Workbench_CraftingHandler {
+
+ private static final Workbench_CraftingHandler instance = new Workbench_CraftingHandler();
+ private List recipes = new ArrayList();
+
+ public static final Workbench_CraftingHandler getInstance() {
+ return instance;
+ }
+ public Workbench_CraftingHandler() {
+
+ //just a example recipe so you know how to add them
+ addRecipe(new ItemStack(Blocks.iron_block), new Object[]
+ {
+ "###",
+ "###",
+ "###",
+ Character.valueOf('#'), Items.iron_ingot
+ });
+
+ //another example Recipe, but shapeless
+ addShapelessRecipe(new ItemStack(Items.cake),new Object[]{Items.stick});
+
+
+ }
+
+ void addRecipe(ItemStack par1ItemStack, Object par2ArrayOfObj[])
+ {
+ String s = "";
+ int i = 0;
+ int j = 0;
+ int k = 0;
+
+ if (par2ArrayOfObj[i] instanceof String[])
+ {
+ String as[] = (String[])par2ArrayOfObj[i++];
+
+ for (int l = 0; l < as.length; l++)
+ {
+ String s2 = as[l];
+ k++;
+ j = s2.length();
+ s = (new StringBuilder()).append(s).append(s2).toString();
+ }
+ }
+ else
+ {
+ while (par2ArrayOfObj[i] instanceof String)
+ {
+ String s1 = (String)par2ArrayOfObj[i++];
+ k++;
+ j = s1.length();
+ s = (new StringBuilder()).append(s).append(s1).toString();
+ }
+ }
+
+ HashMap hashmap = new HashMap();
+
+ for (; i < par2ArrayOfObj.length; i += 2)
+ {
+ Character character = (Character)par2ArrayOfObj[i];
+ ItemStack itemstack = null;
+
+ if (par2ArrayOfObj[i + 1] instanceof Item)
+ {
+ itemstack = new ItemStack((Item)par2ArrayOfObj[i + 1]);
+ }
+ else if (par2ArrayOfObj[i + 1] instanceof Block)
+ {
+ itemstack = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, -1);
+ }
+ else if (par2ArrayOfObj[i + 1] instanceof ItemStack)
+ {
+ itemstack = (ItemStack)par2ArrayOfObj[i + 1];
+ }
+
+ hashmap.put(character, itemstack);
+ }
+
+ ItemStack aitemstack[] = new ItemStack[j * k];
+
+ for (int i1 = 0; i1 < j * k; i1++)
+ {
+ char c = s.charAt(i1);
+
+ if (hashmap.containsKey(Character.valueOf(c)))
+ {
+ aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy();
+ }
+ else
+ {
+ aitemstack[i1] = null;
+ }
+ }
+
+ recipes.add(new ShapedRecipes(j, k, aitemstack, par1ItemStack));
+ }
+
+ public void addShapelessRecipe(ItemStack par1ItemStack, Object par2ArrayOfObj[])
+ {
+ ArrayList arraylist = new ArrayList();
+ Object aobj[] = par2ArrayOfObj;
+ int i = aobj.length;
+
+ for (int j = 0; j < i; j++)
+ {
+ Object obj = aobj[j];
+
+ if (obj instanceof ItemStack)
+ {
+ arraylist.add(((ItemStack)obj).copy());
+ continue;
+ }
+
+ if (obj instanceof Item)
+ {
+ arraylist.add(new ItemStack((Item)obj));
+ continue;
+ }
+
+ if (obj instanceof Block)
+ {
+ arraylist.add(new ItemStack((Block)obj));
+ }
+ else
+ {
+ throw new RuntimeException("Invalid shapeless recipe!");
+ }
+ }
+
+ recipes.add(new ShapelessRecipes(par1ItemStack, arraylist));
+ }
+
+ public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
+ {
+ int i = 0;
+ ItemStack itemstack = null;
+ ItemStack itemstack1 = null;
+
+ for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); j++)
+ {
+ ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);
+
+ if (itemstack2 == null)
+ {
+ continue;
+ }
+
+ if (i == 0)
+ {
+ itemstack = itemstack2;
+ }
+
+ if (i == 1)
+ {
+ itemstack1 = itemstack2;
+ }
+
+ i++;
+ }
+
+ //TODO - Update from itemIDs
+ /*if (i == 2 && itemstack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isDamageable())
+ {
+ Item item = Item.itemsList[itemstack.itemID];
+ int l = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
+ int i1 = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
+ int j1 = l + i1 + (item.getMaxDamage() * 10) / 100;
+ int k1 = item.getMaxDamage() - j1;
+
+ if (k1 < 0)
+ {
+ k1 = 0;
+ }
+
+ return new ItemStack(itemstack.itemID, 1, k1);
+ }*/
+
+ for (int k = 0; k < recipes.size(); k++)
+ {
+ IRecipe irecipe = (IRecipe)recipes.get(k);
+
+ if (irecipe.matches(par1InventoryCrafting, par2World))
+ {
+ return irecipe.getCraftingResult(par1InventoryCrafting);
+ }
+ }
+
+ return null;
+ }
+
+
+ public List getRecipeList()
+ {
+ return recipes;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java b/src/Java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java
new file mode 100644
index 0000000000..79d80aa677
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java
@@ -0,0 +1,43 @@
+package gtPlusPlus.core.handler.workbench;
+
+import java.util.Comparator;
+
+import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.item.crafting.ShapedRecipes;
+import net.minecraft.item.crafting.ShapelessRecipes;
+
+public class Workbench_RecipeSorter implements Comparator
+{
+ final Workbench_CraftingHandler CraftingManagerCrafter;
+
+ Workbench_RecipeSorter(Workbench_CraftingHandler par1CraftingManager)
+ {
+ CraftingManagerCrafter = par1CraftingManager;
+ }
+
+ public int compareRecipes(IRecipe par1IRecipe, IRecipe par2IRecipe)
+ {
+ if ((par1IRecipe instanceof ShapelessRecipes) && (par2IRecipe instanceof ShapedRecipes))
+ {
+ return 1;
+ }
+
+ if ((par2IRecipe instanceof ShapelessRecipes) && (par1IRecipe instanceof ShapedRecipes))
+ {
+ return -1;
+ }
+
+ if (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize())
+ {
+ return -1;
+ }
+
+ return par2IRecipe.getRecipeSize() <= par1IRecipe.getRecipeSize() ? 0 : 1;
+ }
+
+ public int compare(Object par1Obj, Object par2Obj)
+ {
+ return compareRecipes((IRecipe)par1Obj, (IRecipe)par2Obj);
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java
new file mode 100644
index 0000000000..569f99b078
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java
@@ -0,0 +1,183 @@
+package gtPlusPlus.core.inventories;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class InventoryWorkbenchChest implements IInventory{
+
+ private String name = "Inventory Chest";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 16;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public InventoryWorkbenchChest()
+ {
+
+ }
+
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ NBTTagList list = nbt.getTagList("Items", 10);
+ inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++)
+ {
+ NBTTagCompound data = list.getCompoundTagAt(i);
+ int slot = data.getInteger("Slot");
+ if(slot >= 0 && slot < INV_SIZE)
+ {
+ inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++)
+ {
+ ItemStack stack = inventory[i];
+ if(stack != null)
+ {
+ NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot)
+ {
+ return inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack)
+ {
+ inventory[slot] = stack;
+
+ if (stack != null && stack.stackSize > getInventoryStackLimit())
+ {
+ stack.stackSize = getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < getSizeInventory(); ++i)
+ {
+ if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
+ inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(int slot, ItemStack itemstack)
+ {
+ // Don't want to be able to store the inventory item within itself
+ // Bad things will happen, like losing your inventory
+ // Actually, this needs a custom Slot to work
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java
new file mode 100644
index 0000000000..72454d75ed
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java
@@ -0,0 +1,182 @@
+package gtPlusPlus.core.inventories;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class InventoryWorkbenchCrafting implements IInventory{
+
+ private String name = "Inventory Crafting";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 9;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public InventoryWorkbenchCrafting()
+ {
+
+ }
+
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ NBTTagList list = nbt.getTagList("Items", 10);
+ inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++)
+ {
+ NBTTagCompound data = list.getCompoundTagAt(i);
+ int slot = data.getInteger("Slot");
+ if(slot >= 0 && slot < INV_SIZE)
+ {
+ inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++)
+ {
+ ItemStack stack = inventory[i];
+ if(stack != null)
+ {
+ NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot)
+ {
+ return inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack)
+ {
+ inventory[slot] = stack;
+
+ if (stack != null && stack.stackSize > getInventoryStackLimit())
+ {
+ stack.stackSize = getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < getSizeInventory(); ++i)
+ {
+ if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
+ inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(int slot, ItemStack itemstack)
+ {
+ // Don't want to be able to store the inventory item within itself
+ // Bad things will happen, like losing your inventory
+ // Actually, this needs a custom Slot to work
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java
new file mode 100644
index 0000000000..00ecd94574
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java
@@ -0,0 +1,184 @@
+package gtPlusPlus.core.inventories;
+
+import gregtech.api.interfaces.IToolStats;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class InventoryWorkbenchTools implements IInventory{
+
+ private String name = "Inventory Tools";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 5;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public InventoryWorkbenchTools()
+ {
+
+ }
+
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ NBTTagList list = nbt.getTagList("Items", 10);
+ inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++)
+ {
+ NBTTagCompound data = list.getCompoundTagAt(i);
+ int slot = data.getInteger("Slot");
+ if(slot >= 0 && slot < INV_SIZE)
+ {
+ inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++)
+ {
+ ItemStack stack = inventory[i];
+ if(stack != null)
+ {
+ NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot)
+ {
+ return inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack)
+ {
+ inventory[slot] = stack;
+
+ if (stack != null && stack.stackSize > getInventoryStackLimit())
+ {
+ stack.stackSize = getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 1;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < getSizeInventory(); ++i)
+ {
+ if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
+ inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(int slot, ItemStack itemstack)
+ {
+ // Don't want to be able to store the inventory item within itself
+ // Bad things will happen, like losing your inventory
+ // Actually, this needs a custom Slot to work
+ return (itemstack.getItem() instanceof IToolStats);
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/slots/SlotCrafting.java b/src/Java/gtPlusPlus/core/slots/SlotCrafting.java
new file mode 100644
index 0000000000..0c9989158d
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotCrafting.java
@@ -0,0 +1,164 @@
+package gtPlusPlus.core.slots;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemHoe;
+import net.minecraft.item.ItemPickaxe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.ItemSword;
+import net.minecraft.stats.AchievementList;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
+import cpw.mods.fml.common.FMLCommonHandler;
+
+public class SlotCrafting extends Slot
+{
+ /** The craft matrix inventory linked to this result slot. */
+ private final IInventory craftMatrix;
+ /** The player that is using the GUI where this slot resides. */
+ private EntityPlayer thePlayer;
+ /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */
+ private int amountCrafted;
+ private static final String __OBFID = "CL_00001761";
+
+ public SlotCrafting(EntityPlayer p_i1823_1_, IInventory p_i1823_2_, IInventory p_i1823_3_, int p_i1823_4_, int p_i1823_5_, int p_i1823_6_)
+ {
+ super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_);
+ this.thePlayer = p_i1823_1_;
+ this.craftMatrix = p_i1823_2_;
+ }
+
+ /**
+ * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
+ */
+ public boolean isItemValid(ItemStack p_75214_1_)
+ {
+ return false;
+ }
+
+ /**
+ * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
+ * stack.
+ */
+ public ItemStack decrStackSize(int p_75209_1_)
+ {
+ if (this.getHasStack())
+ {
+ this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize);
+ }
+
+ return super.decrStackSize(p_75209_1_);
+ }
+
+ /**
+ * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
+ * internal count then calls onCrafting(item).
+ */
+ protected void onCrafting(ItemStack p_75210_1_, int p_75210_2_)
+ {
+ this.amountCrafted += p_75210_2_;
+ this.onCrafting(p_75210_1_);
+ }
+
+ /**
+ * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
+ */
+ protected void onCrafting(ItemStack p_75208_1_)
+ {
+ p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
+ this.amountCrafted = 0;
+
+ if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.crafting_table))
+ {
+ this.thePlayer.addStat(AchievementList.buildWorkBench, 1);
+ }
+
+ if (p_75208_1_.getItem() instanceof ItemPickaxe)
+ {
+ this.thePlayer.addStat(AchievementList.buildPickaxe, 1);
+ }
+
+ if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.furnace))
+ {
+ this.thePlayer.addStat(AchievementList.buildFurnace, 1);
+ }
+
+ if (p_75208_1_.getItem() instanceof ItemHoe)
+ {
+ this.thePlayer.addStat(AchievementList.buildHoe, 1);
+ }
+
+ if (p_75208_1_.getItem() == Items.bread)
+ {
+ this.thePlayer.addStat(AchievementList.makeBread, 1);
+ }
+
+ if (p_75208_1_.getItem() == Items.cake)
+ {
+ this.thePlayer.addStat(AchievementList.bakeCake, 1);
+ }
+
+ if (p_75208_1_.getItem() instanceof ItemPickaxe && ((ItemPickaxe)p_75208_1_.getItem()).func_150913_i() != Item.ToolMaterial.WOOD)
+ {
+ this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1);
+ }
+
+ if (p_75208_1_.getItem() instanceof ItemSword)
+ {
+ this.thePlayer.addStat(AchievementList.buildSword, 1);
+ }
+
+ if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.enchanting_table))
+ {
+ this.thePlayer.addStat(AchievementList.enchantments, 1);
+ }
+
+ if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.bookshelf))
+ {
+ this.thePlayer.addStat(AchievementList.bookcase, 1);
+ }
+ }
+
+ public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_)
+ {
+ FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, craftMatrix);
+ this.onCrafting(p_82870_2_);
+
+ for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
+ {
+ ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
+
+ if (itemstack1 != null)
+ {
+ this.craftMatrix.decrStackSize(i, 1);
+
+ if (itemstack1.getItem().hasContainerItem(itemstack1))
+ {
+ ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
+
+ if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
+ {
+ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
+ continue;
+ }
+
+ if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2))
+ {
+ if (this.craftMatrix.getStackInSlot(i) == null)
+ {
+ this.craftMatrix.setInventorySlotContents(i, itemstack2);
+ }
+ else
+ {
+ this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/slots/SlotGtTool.java b/src/Java/gtPlusPlus/core/slots/SlotGtTool.java
new file mode 100644
index 0000000000..ec77aa10bd
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotGtTool.java
@@ -0,0 +1,25 @@
+package gtPlusPlus.core.slots;
+
+import gregtech.api.interfaces.IToolStats;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class SlotGtTool extends Slot{
+
+ public SlotGtTool(IInventory inventory, int x, int y, int z) {
+ super(inventory, x, y, z);
+
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack itemstack) {
+ return itemstack.getItem() instanceof IToolStats;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
index 246c7ff285..2028e19787 100644
--- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
+++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
@@ -1,6 +1,8 @@
package gtPlusPlus.core.tileentities;
+import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
import gtPlusPlus.core.util.Utils;
+import cpw.mods.fml.common.registry.GameRegistry;
public class ModTileEntities {
@@ -12,6 +14,7 @@ public class ModTileEntities {
//GameRegistry.registerTileEntity(TileEntityNHG.class, "NuclearFueledHeliumGenerator");
//GameRegistry.registerTileEntity(TileEntityCharger.class, "TE_Charger");
// GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium");
+ GameRegistry.registerTileEntity(TileEntityWorkbench.class, "TileWorkbench");
}
}
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java
new file mode 100644
index 0000000000..df06f92811
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java
@@ -0,0 +1,52 @@
+package gtPlusPlus.core.tileentities.machines;
+
+import gtPlusPlus.core.inventories.InventoryWorkbenchChest;
+import gtPlusPlus.core.inventories.InventoryWorkbenchCrafting;
+import gtPlusPlus.core.inventories.InventoryWorkbenchTools;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class TileEntityWorkbench extends TileEntity {
+
+ public InventoryWorkbenchChest inventoryChest;
+ public InventoryWorkbenchTools inventoryTool;
+ public InventoryWorkbenchCrafting inventoryCrafting;
+
+
+ public TileEntityWorkbench(){
+ this.inventoryCrafting = new InventoryWorkbenchCrafting();//number of slots - without product slot
+ this.inventoryTool = new InventoryWorkbenchTools();//number of slots - without product slot
+ this.inventoryChest = new InventoryWorkbenchChest();//number of slots - without product slot
+ this.canUpdate();
+ }
+
+ @SuppressWarnings("static-method")
+ public NBTTagCompound getTag(NBTTagCompound nbt, String tag)
+ {
+ if(!nbt.hasKey(tag))
+ {
+ nbt.setTag(tag, new NBTTagCompound());
+ }
+ return nbt.getCompoundTag(tag);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ super.writeToNBT(nbt);
+ inventoryChest.writeToNBT(getTag(nbt, "ContentsChest"));
+ inventoryTool.writeToNBT(getTag(nbt, "ContentsTools"));
+ inventoryCrafting.writeToNBT(getTag(nbt, "ContentsCrafting"));
+
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ super.readFromNBT(nbt);
+ inventoryChest.readFromNBT(nbt.getCompoundTag("ContentsChest"));
+ inventoryTool.readFromNBT(nbt.getCompoundTag("ContentsTools"));
+ inventoryCrafting.readFromNBT(nbt.getCompoundTag("ContentsCrafting"));
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java
index 42d6dc4ad4..63b42ffd05 100644
--- a/src/Java/gtPlusPlus/core/util/Utils.java
+++ b/src/Java/gtPlusPlus/core/util/Utils.java
@@ -44,12 +44,17 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
+import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.EntityRegistry;
public class Utils {
public static final int WILDCARD_VALUE = Short.MAX_VALUE;
+
+ public static final boolean isServer(){
+ return FMLCommonHandler.instance().getEffectiveSide().isServer();
+ }
static class ShortTimerTask extends TimerTask {
@Override
@@ -282,7 +287,7 @@ public class Utils {
return targetArray;
}
- public static List<Object> convertArrayToListFixed(Object[] sourceArray) {
+ public static List<Object> convertArrayToFixedSizeList(Object[] sourceArray) {
List<Object> targetList = Arrays.asList(sourceArray);
return targetList;
}