2013-11-19 18:13:37 +01:00
|
|
|
package mekanism.client.gui;
|
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import mekanism.api.Object3D;
|
|
|
|
import mekanism.common.PacketHandler;
|
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
2013-11-19 23:39:16 +01:00
|
|
|
import mekanism.common.inventory.container.ContainerDigitalMiner;
|
2013-11-20 02:15:03 +01:00
|
|
|
import mekanism.common.miner.ThreadMinerSearch.State;
|
|
|
|
import mekanism.common.network.PacketDigitalMinerGui;
|
|
|
|
import mekanism.common.network.PacketDigitalMinerGui.MinerGuiPacket;
|
2013-11-20 00:16:26 +01:00
|
|
|
import mekanism.common.network.PacketTileEntity;
|
2013-11-19 23:39:16 +01:00
|
|
|
import mekanism.common.tileentity.TileEntityDigitalMiner;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-11-21 20:35:33 +01:00
|
|
|
import net.minecraft.block.Block;
|
2013-11-20 01:30:56 +01:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2013-11-19 23:39:16 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2013-11-20 01:30:56 +01:00
|
|
|
import net.minecraft.item.ItemBlock;
|
2013-11-20 00:16:26 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-11-19 18:13:37 +01:00
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
import org.lwjgl.input.Keyboard;
|
2013-11-19 23:39:16 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class GuiDigitalMiner extends GuiMekanism
|
|
|
|
{
|
|
|
|
public TileEntityDigitalMiner tileEntity;
|
2013-11-20 01:30:56 +01:00
|
|
|
|
|
|
|
public GuiButton startButton;
|
|
|
|
public GuiButton stopButton;
|
|
|
|
public GuiButton configButton;
|
2013-11-19 23:39:16 +01:00
|
|
|
|
|
|
|
public GuiDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity)
|
|
|
|
{
|
|
|
|
super(new ContainerDigitalMiner(inventory, tentity));
|
|
|
|
tileEntity = tentity;
|
|
|
|
|
|
|
|
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")));
|
|
|
|
guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")));
|
2013-11-20 00:56:53 +01:00
|
|
|
|
|
|
|
ySize+=64;
|
2013-11-19 23:39:16 +01:00
|
|
|
}
|
2013-11-20 01:30:56 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
|
|
|
|
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
|
|
|
|
|
|
|
buttonList.clear();
|
|
|
|
startButton = new GuiButton(0, guiWidth + 69, guiHeight + 17, 60, 20, "Start");
|
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
if(tileEntity.searcher.state != State.IDLE && tileEntity.running)
|
2013-11-20 01:30:56 +01:00
|
|
|
{
|
|
|
|
startButton.enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
stopButton = new GuiButton(1, guiWidth + 69, guiHeight + 37, 60, 20, "Stop");
|
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
if(tileEntity.searcher.state == State.IDLE || !tileEntity.running)
|
2013-11-20 01:30:56 +01:00
|
|
|
{
|
|
|
|
stopButton.enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
configButton = new GuiButton(2, guiWidth + 69, guiHeight + 57, 60, 20, "Config");
|
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
if(tileEntity.searcher.state != State.IDLE)
|
2013-11-20 01:30:56 +01:00
|
|
|
{
|
|
|
|
configButton.enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonList.add(startButton);
|
|
|
|
buttonList.add(stopButton);
|
|
|
|
buttonList.add(configButton);
|
|
|
|
}
|
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton guibutton)
|
|
|
|
{
|
|
|
|
super.actionPerformed(guibutton);
|
|
|
|
|
|
|
|
if(guibutton.id == 0)
|
|
|
|
{
|
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add(3);
|
|
|
|
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
|
|
|
}
|
|
|
|
else if(guibutton.id == 1)
|
|
|
|
{
|
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add(4);
|
|
|
|
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
|
|
|
}
|
|
|
|
else if(guibutton.id == 2)
|
|
|
|
{
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-20 01:30:56 +01:00
|
|
|
@Override
|
|
|
|
public void updateScreen()
|
|
|
|
{
|
|
|
|
super.updateScreen();
|
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
if(tileEntity.searcher.state != State.IDLE && tileEntity.running)
|
2013-11-20 01:30:56 +01:00
|
|
|
{
|
|
|
|
startButton.enabled = false;
|
|
|
|
}
|
2013-11-20 02:15:03 +01:00
|
|
|
else {
|
|
|
|
startButton.enabled = true;
|
|
|
|
}
|
2013-11-20 01:30:56 +01:00
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
if(tileEntity.searcher.state == State.IDLE || !tileEntity.running)
|
2013-11-20 01:30:56 +01:00
|
|
|
{
|
|
|
|
stopButton.enabled = false;
|
|
|
|
}
|
2013-11-20 02:15:03 +01:00
|
|
|
else {
|
|
|
|
stopButton.enabled = true;
|
|
|
|
}
|
2013-11-20 01:30:56 +01:00
|
|
|
|
2013-11-20 02:15:03 +01:00
|
|
|
if(tileEntity.searcher.state != State.IDLE)
|
2013-11-20 01:30:56 +01:00
|
|
|
{
|
|
|
|
configButton.enabled = false;
|
|
|
|
}
|
2013-11-20 02:15:03 +01:00
|
|
|
else {
|
|
|
|
configButton.enabled = true;
|
|
|
|
}
|
2013-11-20 01:30:56 +01:00
|
|
|
}
|
2013-11-19 23:39:16 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
2013-11-20 04:27:28 +01:00
|
|
|
{
|
2013-11-19 23:39:16 +01:00
|
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
|
|
|
|
2013-11-22 04:30:01 +01:00
|
|
|
fontRenderer.drawString(tileEntity.fullName, 69, 6, 0x404040);
|
2013-11-19 23:39:16 +01:00
|
|
|
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
2013-11-20 00:16:26 +01:00
|
|
|
|
2013-11-22 04:30:01 +01:00
|
|
|
fontRenderer.drawString(tileEntity.running ? "Running" : "Idle", 9, 10, 0x00CD00);
|
|
|
|
fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00);
|
2013-11-20 02:15:03 +01:00
|
|
|
|
2013-11-22 04:30:01 +01:00
|
|
|
fontRenderer.drawString("Eject: " + (tileEntity.doEject ? "On" : "Off"), 9, 30, 0x00CD00);
|
|
|
|
fontRenderer.drawString("Pull: " + (tileEntity.doPull ? "On" : "Off"), 9, 39, 0x00CD00);
|
|
|
|
fontRenderer.drawString("Silk: " + (tileEntity.silkTouch ? "On" : "Off"), 9, 48, 0x00CD00);
|
2013-11-20 04:27:28 +01:00
|
|
|
|
|
|
|
fontRenderer.drawString("To mine:", 9, 59, 0x00CD00);
|
|
|
|
fontRenderer.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00);
|
2013-11-20 02:15:03 +01:00
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
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();
|
|
|
|
}
|
2013-11-19 23:39:16 +01:00
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
if(xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77)
|
|
|
|
{
|
2013-11-23 02:58:49 +01:00
|
|
|
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
|
2013-11-20 00:16:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2013-11-20 01:30:56 +01:00
|
|
|
|
|
|
|
if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43)
|
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText("Replace block", xAxis, yAxis);
|
|
|
|
}
|
2013-11-20 04:13:35 +01:00
|
|
|
|
|
|
|
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61)
|
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText("Reset", xAxis, yAxis);
|
|
|
|
}
|
2013-11-20 04:27:28 +01:00
|
|
|
|
2013-11-22 04:30:01 +01:00
|
|
|
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77)
|
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText("Silk touch", xAxis, yAxis);
|
|
|
|
}
|
|
|
|
|
2013-11-20 04:27:28 +01:00
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
2013-11-19 23:39:16 +01:00
|
|
|
}
|
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
@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);
|
|
|
|
}
|
2013-11-20 00:56:53 +01:00
|
|
|
|
2013-11-20 04:13:35 +01:00
|
|
|
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 0, 14, 14);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 14, 14, 14);
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:30:01 +01:00
|
|
|
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 0, 14, 14);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14);
|
|
|
|
}
|
|
|
|
|
2013-11-20 00:56:53 +01:00
|
|
|
if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
int x = guiWidth + 144;
|
|
|
|
int y = guiHeight + 27;
|
|
|
|
drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433);
|
|
|
|
|
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2013-11-20 00:16:26 +01:00
|
|
|
}
|
2013-11-19 23:39:16 +01:00
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
@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);
|
|
|
|
|
2013-11-20 04:13:35 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
|
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add(5);
|
|
|
|
|
2013-11-20 00:16:26 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:30:01 +01:00
|
|
|
if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
|
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add(9);
|
|
|
|
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
|
|
|
}
|
|
|
|
|
2013-11-20 00:56:53 +01:00
|
|
|
if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43)
|
2013-11-20 00:16:26 +01:00
|
|
|
{
|
2013-11-20 00:56:53 +01:00
|
|
|
boolean doNull = false;
|
2013-11-20 00:16:26 +01:00
|
|
|
ItemStack stack = mc.thePlayer.inventory.getItemStack();
|
2013-11-20 00:56:53 +01:00
|
|
|
ItemStack toUse = null;
|
2013-11-20 00:16:26 +01:00
|
|
|
|
|
|
|
if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
|
|
|
{
|
2013-11-20 01:30:56 +01:00
|
|
|
if(stack.getItem() instanceof ItemBlock)
|
|
|
|
{
|
2013-11-21 20:35:33 +01:00
|
|
|
if(stack.itemID != Block.bedrock.blockID)
|
|
|
|
{
|
|
|
|
toUse = stack.copy();
|
|
|
|
}
|
2013-11-20 01:30:56 +01:00
|
|
|
}
|
2013-11-20 00:16:26 +01:00
|
|
|
}
|
|
|
|
else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
|
|
|
{
|
2013-11-20 00:56:53 +01:00
|
|
|
doNull = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(stack != null || doNull)
|
|
|
|
{
|
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add(2);
|
|
|
|
|
|
|
|
if(stack != null)
|
|
|
|
{
|
2013-11-20 01:30:56 +01:00
|
|
|
data.add(false);
|
2013-11-20 00:56:53 +01:00
|
|
|
data.add(stack.itemID);
|
|
|
|
data.add(stack.getItemDamage());
|
|
|
|
}
|
|
|
|
else {
|
2013-11-20 01:30:56 +01:00
|
|
|
data.add(true);
|
2013-11-20 00:56:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
2013-11-20 00:16:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-19 18:13:37 +01:00
|
|
|
}
|