diff --git a/common/mekanism/client/ClientProxy.java b/common/mekanism/client/ClientProxy.java index e230ee2c8..1a6c0dcd4 100644 --- a/common/mekanism/client/ClientProxy.java +++ b/common/mekanism/client/ClientProxy.java @@ -10,6 +10,7 @@ import mekanism.client.gui.GuiCombiner; import mekanism.client.gui.GuiConfiguration; import mekanism.client.gui.GuiCredits; import mekanism.client.gui.GuiCrusher; +import mekanism.client.gui.GuiDigitalMiner; import mekanism.client.gui.GuiDynamicTank; import mekanism.client.gui.GuiElectricChest; import mekanism.client.gui.GuiElectricPump; @@ -300,7 +301,7 @@ public class ClientProxy extends CommonProxy case 1: return new GuiCredits(); case 2: - //DigitalMiner GUI TODO + return new GuiDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity); case 3: return new GuiEnrichmentChamber(player.inventory, (TileEntityElectricMachine)tileEntity); case 4: diff --git a/common/mekanism/client/gui/GuiDigitalMiner.java b/common/mekanism/client/gui/GuiDigitalMiner.java index 4c568e644..484e621d5 100644 --- a/common/mekanism/client/gui/GuiDigitalMiner.java +++ b/common/mekanism/client/gui/GuiDigitalMiner.java @@ -1,11 +1,21 @@ package mekanism.client.gui; +import java.util.ArrayList; + +import mekanism.api.Object3D; +import mekanism.common.PacketHandler; +import mekanism.common.PacketHandler.Transmission; import mekanism.common.inventory.container.ContainerDigitalMiner; +import mekanism.common.network.PacketDigitalMinerGui; +import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket; +import mekanism.common.network.PacketTileEntity; import mekanism.common.tileentity.TileEntityDigitalMiner; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import universalelectricity.core.electricity.ElectricityDisplay; @@ -37,30 +47,114 @@ public class GuiDigitalMiner extends GuiMekanism fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + + if(tileEntity.replaceStack != null) + { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), tileEntity.replaceStack, 144, 27); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) - { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); + if(xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) + { + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); + } + + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) + { + drawCreativeTabHoveringText("Auto-eject", xAxis, yAxis); + } + + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) + { + drawCreativeTabHoveringText("Auto-pull", xAxis, yAxis); + } } -} - -@Override -protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) -{ - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 164, guiHeight + 25 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) + { + drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 0, 14, 14); + } + else { + drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 14, 14, 14); + } + + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) + { + drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 0, 14, 14); + } + else { + drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 14, 14, 14); + } + } - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 7 + 52 - displayInt, 4, displayInt); -} + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + if(button == 0) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + ArrayList data = new ArrayList(); + data.add(0); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data)); + } + + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + ArrayList data = new ArrayList(); + data.add(1); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data)); + } + + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) + { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + tileEntity.replaceStack = stack.copy(); + tileEntity.replaceStack.stackSize = 1; + } + else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + tileEntity.replaceStack = null; + } + + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + } + } } diff --git a/common/mekanism/client/gui/GuiMItemStackFilter.java b/common/mekanism/client/gui/GuiMItemStackFilter.java index e60c85743..6e4858b3f 100644 --- a/common/mekanism/client/gui/GuiMItemStackFilter.java +++ b/common/mekanism/client/gui/GuiMItemStackFilter.java @@ -2,27 +2,23 @@ package mekanism.client.gui; import mekanism.api.EnumColor; import mekanism.api.Object3D; -import mekanism.client.render.MekanismRenderer; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.inventory.container.ContainerFilter; import mekanism.common.miner.MItemStackFilter; +import mekanism.common.network.PacketDigitalMinerGui; +import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket; import mekanism.common.network.PacketEditFilter; -import mekanism.common.network.PacketLogisticalSorterGui; -import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket; import mekanism.common.network.PacketNewFilter; import mekanism.common.tileentity.TileEntityDigitalMiner; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; -import mekanism.common.util.TransporterUtils; import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; public class GuiMItemStackFilter extends GuiMekanism { @@ -90,7 +86,7 @@ public class GuiMItemStackFilter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), false, origFilter, filter)); } - PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0)); } else if(filter.itemType == null) { @@ -101,7 +97,7 @@ public class GuiMItemStackFilter extends GuiMekanism else if(guibutton.id == 1) { PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), true, origFilter)); - PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0)); } } @@ -205,7 +201,7 @@ public class GuiMItemStackFilter extends GuiMekanism if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0)); } if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) diff --git a/common/mekanism/client/gui/GuiMOreDictFilter.java b/common/mekanism/client/gui/GuiMOreDictFilter.java index ab03e41f7..7569c89c5 100644 --- a/common/mekanism/client/gui/GuiMOreDictFilter.java +++ b/common/mekanism/client/gui/GuiMOreDictFilter.java @@ -9,9 +9,9 @@ import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.inventory.container.ContainerFilter; import mekanism.common.miner.MOreDictFilter; +import mekanism.common.network.PacketDigitalMinerGui; +import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket; import mekanism.common.network.PacketEditFilter; -import mekanism.common.network.PacketLogisticalSorterGui; -import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket; import mekanism.common.network.PacketNewFilter; import mekanism.common.tileentity.TileEntityDigitalMiner; import mekanism.common.util.MekanismUtils; @@ -132,7 +132,7 @@ public class GuiMOreDictFilter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), false, origFilter, filter)); } - PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0)); } else { status = EnumColor.DARK_RED + "No key"; @@ -142,7 +142,7 @@ public class GuiMOreDictFilter extends GuiMekanism else if(guibutton.id == 1) { PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), true, origFilter)); - PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0)); } } @@ -257,7 +257,7 @@ public class GuiMOreDictFilter extends GuiMekanism if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0)); } if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index 31e2379f3..03cd397cd 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -3,6 +3,7 @@ package mekanism.common; import java.io.File; import mekanism.common.inventory.container.ContainerAdvancedElectricMachine; +import mekanism.common.inventory.container.ContainerDigitalMiner; import mekanism.common.inventory.container.ContainerDynamicTank; import mekanism.common.inventory.container.ContainerElectricMachine; import mekanism.common.inventory.container.ContainerElectricPump; @@ -244,7 +245,7 @@ public class CommonProxy switch(ID) { case 2: - //DIGITAL MINER CONTAINER TODO + return new ContainerDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity); case 3: return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine)tileEntity); case 4: diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index 27e3f1df5..c8bcde116 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -362,6 +362,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds { return icons[blockID][11][0]; } + else if(meta == 4) + { + return icons[blockID][0][2]; //TODO + } } return null; @@ -480,6 +484,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds { return icons[blockID][11][0]; } + else if(metadata == 4) + { + return icons[blockID][0][2]; //TODO + } return null; } @@ -498,7 +506,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds list.add(new ItemStack(i, 1, 1)); list.add(new ItemStack(i, 1, 2)); list.add(new ItemStack(i, 1, 3)); - //TODO DIGITAL MINER + list.add(new ItemStack(i, 1, 4)); for(RecipeType type : RecipeType.values()) { diff --git a/common/mekanism/common/inventory/container/ContainerDigitalMiner.java b/common/mekanism/common/inventory/container/ContainerDigitalMiner.java index 4c3336d17..12cba0c32 100644 --- a/common/mekanism/common/inventory/container/ContainerDigitalMiner.java +++ b/common/mekanism/common/inventory/container/ContainerDigitalMiner.java @@ -27,7 +27,7 @@ public class ContainerDigitalMiner extends Container } } - addSlotToContainer(new SlotDischarge(tentity, 27, 180, 11)); + addSlotToContainer(new SlotDischarge(tentity, 27, 152, 6)); int slotX; @@ -53,6 +53,7 @@ public class ContainerDigitalMiner extends Container { super.onContainerClosed(entityplayer); + tileEntity.closeChest(); tileEntity.playersUsing.remove(entityplayer); } diff --git a/common/mekanism/common/network/PacketDigitalMinerGui.java b/common/mekanism/common/network/PacketDigitalMinerGui.java index a9b73c072..77de26100 100644 --- a/common/mekanism/common/network/PacketDigitalMinerGui.java +++ b/common/mekanism/common/network/PacketDigitalMinerGui.java @@ -1,6 +1,7 @@ package mekanism.common.network; import java.io.DataOutputStream; +import java.util.ArrayList; import mekanism.api.Object3D; import mekanism.client.gui.GuiDigitalMiner; @@ -145,6 +146,16 @@ public class PacketDigitalMinerGui implements IMekanismPacket playerMP.openContainer = container; playerMP.openContainer.windowId = window; playerMP.openContainer.addCraftingToCrafters(playerMP); + + if(guiType == 0) + { + TileEntityDigitalMiner tile = (TileEntityDigitalMiner)obj.getTileEntity(world); + + for(EntityPlayer player : tile.playersUsing) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(obj, tile.getFilterPacket(new ArrayList())), player); + } + } } @SideOnly(Side.CLIENT) diff --git a/common/mekanism/common/tileentity/TileEntityDigitalMiner.java b/common/mekanism/common/tileentity/TileEntityDigitalMiner.java index d0458fc62..3b7b9249f 100644 --- a/common/mekanism/common/tileentity/TileEntityDigitalMiner.java +++ b/common/mekanism/common/tileentity/TileEntityDigitalMiner.java @@ -183,6 +183,20 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public void handlePacketData(ByteArrayDataInput dataStream) { + if(!worldObj.isRemote) + { + int type = dataStream.readInt(); + + if(type == 0) + { + doEject = !doEject; + } + else if(type == 1) + { + doPull = !doPull; + } + } + super.handlePacketData(dataStream); int type = dataStream.readInt(); @@ -249,15 +263,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I return data; } - @Override - public void openChest() - { - if(!worldObj.isRemote) - { - PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getFilterPacket(new ArrayList())), Object3D.get(this), 50D); - } - } - public ArrayList getGenericPacket(ArrayList data) { super.getNetworkedData(data); diff --git a/resources/assets/mekanism/gui/GuiDigitalMiner.png b/resources/assets/mekanism/gui/GuiDigitalMiner.png index 943558d24..6f160d518 100644 Binary files a/resources/assets/mekanism/gui/GuiDigitalMiner.png and b/resources/assets/mekanism/gui/GuiDigitalMiner.png differ