2013-01-21 02:15:59 +01:00
|
|
|
package mekanism.client;
|
|
|
|
|
2013-02-27 02:21:30 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.api.Object3D;
|
2013-01-21 02:15:59 +01:00
|
|
|
import mekanism.common.ContainerTeleporter;
|
|
|
|
import mekanism.common.PacketHandler;
|
|
|
|
import mekanism.common.TileEntityTeleporter;
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
|
|
|
import mekanism.common.network.PacketTileEntity;
|
2013-01-21 02:15:59 +01:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-05-20 00:43:01 +02:00
|
|
|
import universalelectricity.core.electricity.ElectricityDisplay;
|
|
|
|
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
|
|
|
|
2013-04-13 16:33:37 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-01-21 02:15:59 +01:00
|
|
|
public class GuiTeleporter extends GuiContainer
|
|
|
|
{
|
|
|
|
public TileEntityTeleporter tileEntity;
|
|
|
|
|
|
|
|
public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity)
|
|
|
|
{
|
|
|
|
super(new ContainerTeleporter(inventory, tentity));
|
|
|
|
tileEntity = tentity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-05-20 00:43:01 +02:00
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
2013-01-21 02:15:59 +01:00
|
|
|
{
|
2013-05-20 00:43:01 +02:00
|
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
|
|
|
|
2013-01-21 02:15:59 +01:00
|
|
|
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
|
|
|
|
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
|
|
|
fontRenderer.drawString(tileEntity.status, 66, 19, 0x00CD00);
|
2013-05-20 00:43:01 +02:00
|
|
|
|
|
|
|
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis);
|
|
|
|
}
|
2013-01-21 02:15:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void mouseClicked(int x, int y, int button)
|
|
|
|
{
|
|
|
|
super.mouseClicked(x, y, button);
|
|
|
|
|
|
|
|
int xAxis = (x - (width - xSize) / 2);
|
|
|
|
int yAxis = (y - (height - ySize) / 2);
|
|
|
|
|
2013-02-27 02:21:30 +01:00
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
|
2013-01-21 02:15:59 +01:00
|
|
|
if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-02-27 02:21:30 +01:00
|
|
|
data.add(0);
|
|
|
|
data.add(getIncrementedNumber(tileEntity.code.digitOne));
|
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
2013-01-21 02:15:59 +01:00
|
|
|
tileEntity.code.digitOne = getIncrementedNumber(tileEntity.code.digitOne);
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
else if(xAxis > 62 && xAxis < 76 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-02-27 02:21:30 +01:00
|
|
|
data.add(1);
|
|
|
|
data.add(getIncrementedNumber(tileEntity.code.digitTwo));
|
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
2013-01-21 02:15:59 +01:00
|
|
|
tileEntity.code.digitTwo = getIncrementedNumber(tileEntity.code.digitTwo);
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
else if(xAxis > 101 && xAxis < 115 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-02-27 02:21:30 +01:00
|
|
|
data.add(2);
|
|
|
|
data.add(getIncrementedNumber(tileEntity.code.digitThree));
|
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
2013-01-21 02:15:59 +01:00
|
|
|
tileEntity.code.digitThree = getIncrementedNumber(tileEntity.code.digitThree);
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
else if(xAxis > 140 && xAxis < 154 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-02-27 02:21:30 +01:00
|
|
|
data.add(3);
|
|
|
|
data.add(getIncrementedNumber(tileEntity.code.digitFour));
|
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
2013-01-21 02:15:59 +01:00
|
|
|
tileEntity.code.digitFour = getIncrementedNumber(tileEntity.code.digitFour);
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
|
|
|
{
|
2013-03-25 17:00:45 +01:00
|
|
|
mc.renderEngine.bindTexture("/mods/mekanism/gui/GuiTeleporter.png");
|
2013-01-21 02:15:59 +01:00
|
|
|
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 displayInt;
|
|
|
|
|
|
|
|
displayInt = tileEntity.getScaledEnergyLevel(52);
|
|
|
|
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 13, 52 - displayInt, 4, displayInt);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(tileEntity.code.digitOne);
|
|
|
|
drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(tileEntity.code.digitTwo);
|
|
|
|
drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(tileEntity.code.digitThree);
|
|
|
|
drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(tileEntity.code.digitFour);
|
|
|
|
drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getIncrementedNumber(int i)
|
|
|
|
{
|
2013-05-20 00:43:01 +02:00
|
|
|
if(i < 9)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else if(i == 9)
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
}
|
2013-01-21 02:15:59 +01:00
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getYAxisForNumber(int i)
|
|
|
|
{
|
|
|
|
return i*13;
|
|
|
|
}
|
|
|
|
}
|