2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.gui;
|
2013-05-20 19:51:18 +02:00
|
|
|
|
|
|
|
import mekanism.common.Mekanism;
|
|
|
|
import mekanism.common.PacketHandler;
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.entity.EntityRobit;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.inventory.container.ContainerRobitSmelting;
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.common.network.PacketRobit;
|
|
|
|
import mekanism.common.network.PacketRobit.RobitPacketType;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-05-20 19:51:18 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2013-08-27 00:49:32 +02:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
public class GuiRobitSmelting extends GuiMekanism
|
2013-05-20 19:51:18 +02:00
|
|
|
{
|
|
|
|
public EntityRobit robit;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
public GuiRobitSmelting(InventoryPlayer inventory, EntityRobit entity)
|
|
|
|
{
|
|
|
|
super(new ContainerRobitSmelting(inventory, entity));
|
|
|
|
xSize += 25;
|
|
|
|
robit = entity;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
fontRenderer.drawString(MekanismUtils.localize("gui.robit.smelting"), 8, 6, 0x404040);
|
|
|
|
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040);
|
|
|
|
|
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
|
|
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitSmelting.png"));
|
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
|
|
|
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 21:06:10 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108)
|
|
|
|
{
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
|
|
|
int displayInt;
|
|
|
|
|
|
|
|
if(robit.furnaceBurnTime > 0)
|
|
|
|
{
|
|
|
|
displayInt = getBurnTimeRemainingScaled(12);
|
|
|
|
drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176 + 25 + 18, 36 + 12 - displayInt, 14, displayInt + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
displayInt = getCookProgressScaled(24);
|
|
|
|
drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176 + 25 + 18, 36 + 14, displayInt + 1, 16);
|
|
|
|
}
|
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
@Override
|
|
|
|
protected void mouseClicked(int mouseX, int mouseY, int button)
|
|
|
|
{
|
|
|
|
super.mouseClicked(mouseX, mouseY, button);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
if(button == 0)
|
|
|
|
{
|
|
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 19:51:18 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketRobit().setParams(RobitPacketType.GUI, 0, robit.entityId));
|
2013-05-20 19:51:18 +02:00
|
|
|
mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.entityId, 0, 0);
|
|
|
|
}
|
|
|
|
else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketRobit().setParams(RobitPacketType.GUI, 1, robit.entityId));
|
2013-05-20 19:51:18 +02:00
|
|
|
mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.entityId, 0, 0);
|
|
|
|
}
|
|
|
|
else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketRobit().setParams(RobitPacketType.GUI, 2, robit.entityId));
|
2013-05-20 19:51:18 +02:00
|
|
|
mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.entityId, 0, 0);
|
|
|
|
}
|
|
|
|
else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
|
|
|
}
|
2013-05-20 21:06:10 +02:00
|
|
|
else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108)
|
|
|
|
{
|
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketRobit().setParams(RobitPacketType.GUI, 4, robit.entityId));
|
2013-05-20 21:06:10 +02:00
|
|
|
mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.entityId, 0, 0);
|
|
|
|
}
|
2013-05-20 19:51:18 +02:00
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
|
|
|
private int getCookProgressScaled(int i)
|
|
|
|
{
|
|
|
|
return robit.furnaceCookTime * i / 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
private int getBurnTimeRemainingScaled(int i)
|
|
|
|
{
|
|
|
|
if(robit.currentItemBurnTime == 0)
|
|
|
|
{
|
|
|
|
robit.currentItemBurnTime = 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
return robit.furnaceBurnTime * i / robit.currentItemBurnTime;
|
|
|
|
}
|
2013-05-20 19:51:18 +02:00
|
|
|
}
|