2013-01-21 02:15:59 +01:00
|
|
|
package mekanism.client;
|
|
|
|
|
|
|
|
import mekanism.common.ItemPortableTeleporter;
|
|
|
|
import mekanism.common.PacketHandler;
|
2013-06-07 17:16:47 +02:00
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.common.network.PacketDigitUpdate;
|
|
|
|
import mekanism.common.network.PacketPortableTeleport;
|
2013-01-21 02:15:59 +01:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
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 GuiPortableTeleporter extends GuiScreen
|
|
|
|
{
|
|
|
|
public EntityPlayer entityPlayer;
|
|
|
|
public ItemStack itemStack;
|
|
|
|
|
|
|
|
public int xSize = 176;
|
|
|
|
public int ySize = 166;
|
|
|
|
|
|
|
|
public GuiPortableTeleporter(EntityPlayer player, ItemStack itemstack)
|
|
|
|
{
|
|
|
|
entityPlayer = player;
|
|
|
|
itemStack = itemstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
2013-03-18 17:23:57 +01:00
|
|
|
buttonList.clear();
|
|
|
|
buttonList.add(new GuiButton(0, 173, 105, 80, 20, "Teleport"));
|
2013-01-21 02:15:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawScreen(int i, int j, float f)
|
|
|
|
{
|
|
|
|
if(mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter)
|
|
|
|
{
|
|
|
|
itemStack = mc.thePlayer.getCurrentEquippedItem();
|
|
|
|
}
|
|
|
|
|
2013-03-25 17:00:45 +01:00
|
|
|
mc.renderEngine.bindTexture("/mods/mekanism/gui/GuiPortableTeleporter.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 = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0));
|
|
|
|
drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1));
|
|
|
|
drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2));
|
|
|
|
drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3));
|
|
|
|
drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13);
|
|
|
|
|
|
|
|
ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem();
|
|
|
|
|
2013-03-18 17:23:57 +01:00
|
|
|
((GuiButton)buttonList.get(0)).xPosition = guiWidth+48;
|
|
|
|
((GuiButton)buttonList.get(0)).yPosition = guiHeight+68;
|
2013-01-23 21:42:45 +01:00
|
|
|
|
|
|
|
fontRenderer.drawString("Portable Teleporter", guiWidth+39, guiHeight+6, 0x404040);
|
|
|
|
fontRenderer.drawString(item.getStatusAsString(item.getStatus(itemStack)), guiWidth+53, guiHeight+19, 0x00CD00);
|
2013-01-21 02:15:59 +01:00
|
|
|
super.drawScreen(i, j, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton guibutton)
|
|
|
|
{
|
|
|
|
if(guibutton.id == 0)
|
|
|
|
{
|
2013-06-13 23:37:30 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketPortableTeleport());
|
2013-03-28 18:27:27 +01:00
|
|
|
mc.setIngameFocus();
|
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);
|
|
|
|
|
|
|
|
if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitUpdate().setParams(0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0))));
|
2013-01-21 02:15:59 +01:00
|
|
|
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0)));
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
else if(xAxis > 62 && xAxis < 76 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitUpdate().setParams(1, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1))));
|
2013-01-21 02:15:59 +01:00
|
|
|
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 1, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1)));
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
else if(xAxis > 101 && xAxis < 115 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitUpdate().setParams(2, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2))));
|
2013-01-21 02:15:59 +01:00
|
|
|
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 2, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2)));
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
else if(xAxis > 140 && xAxis < 154 && yAxis > 44 && yAxis < 58)
|
|
|
|
{
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitUpdate().setParams(3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3))));
|
2013-01-21 02:15:59 +01:00
|
|
|
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3)));
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getIncrementedNumber(int i)
|
|
|
|
{
|
|
|
|
if(i < 9) i++;
|
|
|
|
else if(i == 9) i=0;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getYAxisForNumber(int i)
|
|
|
|
{
|
|
|
|
return i*13;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doesGuiPauseGame()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|