diff --git a/common/mekanism/client/gui/GuiDigitalMinerConfig.java b/common/mekanism/client/gui/GuiDigitalMinerConfig.java index 019209c78..c15a7fd3c 100644 --- a/common/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/common/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -17,6 +17,7 @@ import mekanism.common.miner.MinerFilter; import mekanism.common.network.PacketDigitalMinerGui; import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket; import mekanism.common.network.PacketSimpleGui; +import mekanism.common.network.PacketTileEntity; import mekanism.common.tileentity.TileEntityDigitalMiner; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -185,6 +186,24 @@ public class GuiDigitalMinerConfig extends GuiMekanism mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketSimpleGui().setParams(Object3D.get(tileEntity), 2)); } + + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + setRadius(); + } + + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + setMinY(); + } + + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + setMaxY(); + } } } @@ -226,19 +245,19 @@ public class GuiDigitalMinerConfig extends GuiMekanism buttonList.add(new GuiButton(0, guiWidth + 56, guiHeight + 136, 54, 20, "ItemStack")); buttonList.add(new GuiButton(1, guiWidth + 110, guiHeight + 136, 43, 20, "OreDict")); - String prevRad = radiusField != null ? radiusField.getText() : "" + tileEntity.radius; - String prevMin = minField != null ? minField.getText() : "" + tileEntity.minY; - String prevMax = maxField != null ? maxField.getText() : "" + tileEntity.maxY; + String prevRad = radiusField != null ? radiusField.getText() : ""; + String prevMin = minField != null ? minField.getText() : ""; + String prevMax = maxField != null ? maxField.getText() : ""; radiusField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 67, 26, 11); - radiusField.setMaxStringLength(3); + radiusField.setMaxStringLength(2); radiusField.setText(prevRad); - minField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 92, 20, 11); + minField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 92, 26, 11); minField.setMaxStringLength(3); minField.setText(prevMin); - maxField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 117, 20, 11); + maxField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 117, 26, 11); maxField.setMaxStringLength(3); maxField.setText(prevMax); } @@ -264,7 +283,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - fontRenderer.drawString("Logistical Sorter", 43, 6, 0x404040); + fontRenderer.drawString("Digital Miner Config", 43, 6, 0x404040); fontRenderer.drawString("Filters:", 11, 19, 0x00CD00); fontRenderer.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); @@ -361,14 +380,6 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - drawTexturedModalRect(guiWidth + 12, guiHeight + 84, 176 + 14, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 12, guiHeight + 84, 176 + 14, 14, 14, 14); - } - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); @@ -377,6 +388,30 @@ public class GuiDigitalMinerConfig extends GuiMekanism drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); } + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) + { + drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 0, 11, 11); + } + else { + drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 11, 11, 11); + } + + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) + { + drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 0, 11, 11); + } + else { + drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 11, 11, 11); + } + + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) + { + drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 0, 11, 11); + } + else { + drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 11, 11, 11); + } + radiusField.drawTextBox(); minField.drawTextBox(); maxField.drawTextBox(); @@ -394,24 +429,15 @@ public class GuiDigitalMinerConfig extends GuiMekanism { if(radiusField.isFocused()) { - if(!radiusField.getText().isEmpty()) - { - - } + setRadius(); } else if(minField.isFocused()) { - if(!minField.getText().isEmpty()) - { - - } + setMinY(); } else if(maxField.isFocused()) { - if(!maxField.getText().isEmpty()) - { - - } + setMaxY(); } } @@ -423,6 +449,54 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } + private void setRadius() + { + if(!radiusField.getText().isEmpty()) + { + int toUse = Math.max(0, Math.min(Integer.parseInt(radiusField.getText()), 99)); + + ArrayList data = new ArrayList(); + data.add(6); + data.add(toUse); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data)); + + radiusField.setText(""); + } + } + + private void setMinY() + { + if(!minField.getText().isEmpty()) + { + int toUse = Math.max(0, Math.min(Integer.parseInt(minField.getText()), 255)); + + ArrayList data = new ArrayList(); + data.add(7); + data.add(toUse); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data)); + + minField.setText(""); + } + } + + private void setMaxY() + { + if(!maxField.getText().isEmpty()) + { + int toUse = Math.max(0, Math.min(Integer.parseInt(maxField.getText()), 255)); + + ArrayList data = new ArrayList(); + data.add(8); + data.add(toUse); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data)); + + maxField.setText(""); + } + } + public ArrayList getItemStackFilters() { ArrayList list = new ArrayList(); diff --git a/common/mekanism/client/gui/GuiMItemStackFilter.java b/common/mekanism/client/gui/GuiMItemStackFilter.java index abb958f4b..bb808f4bd 100644 --- a/common/mekanism/client/gui/GuiMItemStackFilter.java +++ b/common/mekanism/client/gui/GuiMItemStackFilter.java @@ -37,7 +37,7 @@ public class GuiMItemStackFilter extends GuiMekanism public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (MItemStackFilter)tileEntity.filters.get(index); @@ -46,7 +46,7 @@ public class GuiMItemStackFilter extends GuiMekanism public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/common/mekanism/client/gui/GuiMOreDictFilter.java b/common/mekanism/client/gui/GuiMOreDictFilter.java index 4f6dd407e..858f89630 100644 --- a/common/mekanism/client/gui/GuiMOreDictFilter.java +++ b/common/mekanism/client/gui/GuiMOreDictFilter.java @@ -52,7 +52,7 @@ public class GuiMOreDictFilter extends GuiMekanism public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (MOreDictFilter)tileEntity.filters.get(index); @@ -63,7 +63,7 @@ public class GuiMOreDictFilter extends GuiMekanism public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/common/mekanism/client/gui/GuiTItemStackFilter.java b/common/mekanism/client/gui/GuiTItemStackFilter.java index a92f5029e..210ff60a7 100644 --- a/common/mekanism/client/gui/GuiTItemStackFilter.java +++ b/common/mekanism/client/gui/GuiTItemStackFilter.java @@ -43,7 +43,7 @@ public class GuiTItemStackFilter extends GuiMekanism public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (TItemStackFilter)tileEntity.filters.get(index); @@ -52,7 +52,7 @@ public class GuiTItemStackFilter extends GuiMekanism public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/common/mekanism/client/gui/GuiTOreDictFilter.java b/common/mekanism/client/gui/GuiTOreDictFilter.java index cae1e74ed..0e5246ec0 100644 --- a/common/mekanism/client/gui/GuiTOreDictFilter.java +++ b/common/mekanism/client/gui/GuiTOreDictFilter.java @@ -56,7 +56,7 @@ public class GuiTOreDictFilter extends GuiMekanism public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; origFilter = (TOreDictFilter)tileEntity.filters.get(index); @@ -67,7 +67,7 @@ public class GuiTOreDictFilter extends GuiMekanism public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { - super(new ContainerFilter(player.inventory)); + super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; isNew = true; diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index 03cd397cd..4b6060879 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -301,9 +301,9 @@ public class CommonProxy case 26: return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); case 27: - return new ContainerFilter(player.inventory); + return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity); case 28: - return new ContainerFilter(player.inventory); + return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity); } return null; diff --git a/common/mekanism/common/inventory/container/ContainerFilter.java b/common/mekanism/common/inventory/container/ContainerFilter.java index 35e74c9c0..29d1b84ca 100644 --- a/common/mekanism/common/inventory/container/ContainerFilter.java +++ b/common/mekanism/common/inventory/container/ContainerFilter.java @@ -1,5 +1,6 @@ package mekanism.common.inventory.container; +import mekanism.common.tileentity.TileEntityContainerBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -8,8 +9,12 @@ import net.minecraft.item.ItemStack; public class ContainerFilter extends Container { - public ContainerFilter(InventoryPlayer inventory) + private TileEntityContainerBlock tileEntity; + + public ContainerFilter(InventoryPlayer inventory, TileEntityContainerBlock tile) { + tileEntity = tile; + int slotX; for(slotX = 0; slotX < 3; ++slotX) @@ -24,12 +29,24 @@ public class ContainerFilter extends Container { addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); } + + tileEntity.openChest(); + tileEntity.playersUsing.add(inventory.player); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { + super.onContainerClosed(entityplayer); + + tileEntity.closeChest(); + tileEntity.playersUsing.remove(entityplayer); } @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return true; + return tileEntity.isUseableByPlayer(entityplayer); } @Override diff --git a/common/mekanism/common/network/PacketDigitalMinerGui.java b/common/mekanism/common/network/PacketDigitalMinerGui.java index 73598d698..8f8b7c18b 100644 --- a/common/mekanism/common/network/PacketDigitalMinerGui.java +++ b/common/mekanism/common/network/PacketDigitalMinerGui.java @@ -121,17 +121,18 @@ public class PacketDigitalMinerGui implements IMekanismPacket { Container container = null; + playerMP.closeScreen(); + if(guiType == 0) { container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); } else if(guiType == 1 || guiType == 2) { - container = new ContainerFilter(playerMP.inventory); + container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); } playerMP.incrementWindowID(); - playerMP.closeContainer(); int window = playerMP.currentWindowId; if(t == MinerGuiPacket.SERVER) diff --git a/common/mekanism/common/network/PacketLogisticalSorterGui.java b/common/mekanism/common/network/PacketLogisticalSorterGui.java index fc42c31da..f71800453 100644 --- a/common/mekanism/common/network/PacketLogisticalSorterGui.java +++ b/common/mekanism/common/network/PacketLogisticalSorterGui.java @@ -121,17 +121,18 @@ public class PacketLogisticalSorterGui implements IMekanismPacket { Container container = null; + playerMP.closeScreen(); + if(guiType == 0) { container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); } else if(guiType == 1 || guiType == 2) { - container = new ContainerFilter(playerMP.inventory); + container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); } playerMP.incrementWindowID(); - playerMP.closeContainer(); int window = playerMP.currentWindowId; if(t == SorterGuiPacket.SERVER) diff --git a/common/mekanism/common/tileentity/TileEntityDigitalMiner.java b/common/mekanism/common/tileentity/TileEntityDigitalMiner.java index 548bcda59..21953c280 100644 --- a/common/mekanism/common/tileentity/TileEntityDigitalMiner.java +++ b/common/mekanism/common/tileentity/TileEntityDigitalMiner.java @@ -138,6 +138,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I doPull = nbtTags.getBoolean("doPull"); isActive = nbtTags.getBoolean("isActive"); running = nbtTags.getBoolean("running"); + searcher.state = State.values()[nbtTags.getInteger("state")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; if(nbtTags.hasKey("replaceStack")) @@ -178,6 +179,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I nbtTags.setBoolean("doPull", doPull); nbtTags.setBoolean("isActive", isActive); nbtTags.setBoolean("running", running); + nbtTags.setInteger("state", searcher.state.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal()); if(replaceStack != null) diff --git a/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png b/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png index 0bb07bb6d..7f12021c7 100644 Binary files a/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png and b/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png differ