diff --git a/common/mekanism/client/gui/GuiItemStackFilter.java b/common/mekanism/client/gui/GuiItemStackFilter.java index 605112a53..d28d74a6b 100644 --- a/common/mekanism/client/gui/GuiItemStackFilter.java +++ b/common/mekanism/client/gui/GuiItemStackFilter.java @@ -171,7 +171,7 @@ public class GuiItemStackFilter extends GuiMekanism if(filter.itemType != null) { - fontRenderer.drawString("ID: " + filter.itemType.itemID + ", meta: " + filter.itemType.getItemDamage(), 35, 41, 0x00CD00); + fontRenderer.drawString("Item: " + filter.itemType.getDisplayName(), 35, 41, 0x00CD00); } if(filter.itemType != null) diff --git a/common/mekanism/client/nei/NEIMekanismConfig.java b/common/mekanism/client/nei/NEIMekanismConfig.java index 7e398a00d..12616c741 100644 --- a/common/mekanism/client/nei/NEIMekanismConfig.java +++ b/common/mekanism/client/nei/NEIMekanismConfig.java @@ -44,6 +44,7 @@ public class NEIMekanismConfig implements IConfigureNEI API.setGuiOffset(GuiMetallurgicInfuser.class, 5, 15); API.hideItem(Mekanism.boundingBlockID); + API.hideItem(Mekanism.ItemProxy.itemID); } @Override diff --git a/common/mekanism/common/BinRecipe.java b/common/mekanism/common/BinRecipe.java index 22aa98b46..a1f42f158 100644 --- a/common/mekanism/common/BinRecipe.java +++ b/common/mekanism/common/BinRecipe.java @@ -2,6 +2,7 @@ package mekanism.common; import mekanism.common.inventory.InventoryBin; import mekanism.common.item.ItemBlockBasic; +import mekanism.common.item.ItemProxy; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; @@ -39,7 +40,7 @@ public class BinRecipe implements IRecipe, ICraftingHandler { ItemStack bin = null; - for(int i = 0; i < 9; i++) + for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); @@ -111,7 +112,26 @@ public class BinRecipe implements IRecipe, ICraftingHandler @Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { - + if(getCraftingResult((InventoryCrafting)craftMatrix) != null) + { + for(int i = 0; i < craftMatrix.getSizeInventory(); i++) + { + if(!isBin(item) && isBin(craftMatrix.getStackInSlot(i))) + { + ItemStack bin = craftMatrix.getStackInSlot(i); + InventoryBin inv = new InventoryBin(bin); + + bin.stackTagCompound.setInteger("newCount", inv.getItemCount()-item.stackSize); + } + else if(isBin(item) && !isBin(craftMatrix.getStackInSlot(i))) + { + ItemStack proxy = new ItemStack(Mekanism.ItemProxy); + ((ItemProxy)proxy.getItem()).setSavedItem(proxy, craftMatrix.getStackInSlot(i)); + + craftMatrix.setInventorySlotContents(i, proxy); + } + } + } } @Override diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index d6425e543..e637e0aaf 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -51,6 +51,7 @@ import mekanism.common.item.ItemMachineUpgrade; import mekanism.common.item.ItemMekanism; import mekanism.common.item.ItemNetworkReader; import mekanism.common.item.ItemPortableTeleporter; +import mekanism.common.item.ItemProxy; import mekanism.common.item.ItemRobit; import mekanism.common.item.ItemWalkieTalkie; import mekanism.common.network.PacketConfigurationUpdate; @@ -73,7 +74,6 @@ import mekanism.common.network.PacketTileEntity; import mekanism.common.network.PacketTransmitterTransferUpdate; import mekanism.common.network.PacketTransmitterTransferUpdate.TransmitterTransferType; import mekanism.common.network.PacketWalkieTalkieState; -import mekanism.common.tileentity.TileEntityBin; import mekanism.common.tileentity.TileEntityBoundingBlock; import mekanism.common.tileentity.TileEntityElectricBlock; import mekanism.common.tileentity.TileEntityTeleporter; @@ -195,6 +195,7 @@ public class Mekanism public static Item NetworkReader; public static Item ManganeseAlloy; public static Item WalkieTalkie; + public static Item ItemProxy; //Blocks public static Block BasicBlock; @@ -434,6 +435,8 @@ public class Mekanism "CAC", "cOc", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.ADVANCED, type) })); } + + CraftingManager.getInstance().getRecipeList().add(new BinRecipe()); //Furnace Recipes FurnaceRecipes.smelting().addSmelting(oreBlockID, 0, new ItemStack(Ingot, 1, 1), 1.0F); @@ -514,7 +517,7 @@ public class Mekanism AtomicDisassembler = (ItemAtomicDisassembler) new ItemAtomicDisassembler(configuration.getItem("AtomicDisassembler", 11210).getInt()).setUnlocalizedName("AtomicDisassembler"); AtomicCore = new ItemMekanism(configuration.getItem("AtomicCore", 11211).getInt()).setUnlocalizedName("AtomicCore"); EnrichedAlloy = new ItemMekanism(configuration.getItem("EnrichedAlloy", 11212).getInt()).setUnlocalizedName("EnrichedAlloy"); - //OPEN 11213 + ItemProxy = new ItemProxy(configuration.getItem("ItemProxy", 11213).getInt()).setUnlocalizedName("ItemProxy"); ControlCircuit = new ItemMekanism(configuration.getItem("ControlCircuit", 11214).getInt()).setUnlocalizedName("ControlCircuit"); EnrichedIron = new ItemMekanism(configuration.getItem("EnrichedIron", 11215).getInt()).setUnlocalizedName("EnrichedIron"); CompressedCarbon = new ItemMekanism(configuration.getItem("CompressedCarbon", 11216).getInt()).setUnlocalizedName("CompressedCarbon"); @@ -539,6 +542,7 @@ public class Mekanism GameRegistry.registerItem(AtomicDisassembler, "AtomicDisassembler"); GameRegistry.registerItem(AtomicCore, "AtomicCore"); GameRegistry.registerItem(EnrichedAlloy, "EnrichedAlloy"); + GameRegistry.registerItem(ItemProxy, "ItemProxy"); GameRegistry.registerItem(ControlCircuit, "ControlCircuit"); GameRegistry.registerItem(EnrichedIron, "EnrichedIron"); GameRegistry.registerItem(CompressedCarbon, "CompressedCarbon"); diff --git a/common/mekanism/common/block/BlockBasic.java b/common/mekanism/common/block/BlockBasic.java index 4fba373c9..799e234bf 100644 --- a/common/mekanism/common/block/BlockBasic.java +++ b/common/mekanism/common/block/BlockBasic.java @@ -8,7 +8,7 @@ import mekanism.client.ClientProxy; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; -import mekanism.common.block.BlockMachine.MachineType; +import mekanism.common.inventory.InventoryBin; import mekanism.common.network.PacketTileEntity; import mekanism.common.tileentity.TileEntityBin; import mekanism.common.tileentity.TileEntityDynamicTank; @@ -22,6 +22,7 @@ import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.util.MovingObjectPosition; @@ -403,6 +404,21 @@ public class BlockBasic extends Block @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(blockID, 1, world.getBlockMetadata(x, y, z)); + ItemStack ret = new ItemStack(blockID, 1, world.getBlockMetadata(x, y, z)); + + if(ret.getItemDamage() == 6) + { + TileEntityBin tileEntity = (TileEntityBin)world.getBlockTileEntity(x, y, z); + InventoryBin inv = new InventoryBin(ret); + + inv.setItemCount(tileEntity.itemCount); + + if(tileEntity.itemCount > 0) + { + inv.setItemType(tileEntity.itemType); + } + } + + return ret; } } \ No newline at end of file diff --git a/common/mekanism/common/item/ItemBlockBasic.java b/common/mekanism/common/item/ItemBlockBasic.java index 57d10c212..f50b60f58 100644 --- a/common/mekanism/common/item/ItemBlockBasic.java +++ b/common/mekanism/common/item/ItemBlockBasic.java @@ -1,9 +1,22 @@ package mekanism.common.item; +import java.util.List; + +import mekanism.api.EnumColor; +import mekanism.common.Mekanism; +import mekanism.common.inventory.InventoryBin; +import mekanism.common.tileentity.TileEntityBin; import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; +import net.minecraft.world.World; + +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * Item class for handling multiple metal block IDs. @@ -45,6 +58,88 @@ public class ItemBlockBasic extends ItemBlock return metaBlock.getIcon(2, i); } + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + { + if(itemstack.getItemDamage() == 6) + { + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for more details."); + } + else { + InventoryBin inv = new InventoryBin(itemstack); + + list.add(EnumColor.INDIGO + "Item color: " + EnumColor.GREY + inv.getItemCount()); + + if(inv.getItemCount() > 0) + { + list.add(EnumColor.BRIGHT_GREEN + "Item type: " + inv.getItemType().getDisplayName()); + } + } + } + } + + @Override + public boolean hasContainerItem() + { + return true; //TODO forge PR + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) + { + if(stack.getItemDamage() != 6) + { + return false; + } + + if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount")) + { + return false; + } + + return true; + } + + @Override + public ItemStack getContainerItemStack(ItemStack stack) + { + if(stack.getItemDamage() != 6 || stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount")) + { + return new ItemStack(Mekanism.ItemProxy); + } + + ItemStack ret = stack.copy(); + ret.stackSize = stack.stackTagCompound.getInteger("newCount"); + return ret; + } + + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) + { + boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + + if(place) + { + if(stack.getItemDamage() == 6 && stack.stackTagCompound != null) + { + TileEntityBin tileEntity = (TileEntityBin)world.getBlockTileEntity(x, y, z); + InventoryBin inv = new InventoryBin(stack); + + tileEntity.itemCount = inv.getItemCount(); + + if(inv.getItemCount() > 0) + { + tileEntity.setItemType(inv.getItemType()); + } + } + } + + return place; + } + @Override public String getUnlocalizedName(ItemStack itemstack) { diff --git a/common/mekanism/common/item/ItemProxy.java b/common/mekanism/common/item/ItemProxy.java new file mode 100644 index 000000000..608945684 --- /dev/null +++ b/common/mekanism/common/item/ItemProxy.java @@ -0,0 +1,69 @@ +package mekanism.common.item; + +import mekanism.common.Mekanism; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ItemProxy extends Item +{ + public ItemProxy(int id) + { + super(id); + } + + @Override + public ItemStack getContainerItemStack(ItemStack stack) + { + return getSavedItem(stack) != null ? getSavedItem(stack) : new ItemStack(Mekanism.ItemProxy); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) + { + return stack.stackTagCompound != null && stack.stackTagCompound.getBoolean("hasStack"); + } + + @Override + public boolean hasContainerItem() + { + return true; //TODO forge PR + } + + public void setSavedItem(ItemStack stack, ItemStack save) + { + if(stack.stackTagCompound == null) + { + stack.setTagCompound(new NBTTagCompound()); + } + + if(save == null) + { + stack.stackTagCompound.setBoolean("hasStack", false); + stack.stackTagCompound.removeTag("savedItem"); + } + else { + stack.stackTagCompound.setBoolean("hasStack", true); + stack.stackTagCompound.setCompoundTag("savedItem", stack.writeToNBT(new NBTTagCompound())); + } + } + + public ItemStack getSavedItem(ItemStack stack) + { + if(stack.stackTagCompound == null) + { + return null; + } + + if(stack.stackTagCompound.getBoolean("hasStack")) + { + return ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("savedItem")); + } + + return null; + } + + @Override + public void registerIcons(IconRegister register) {} +}