Package logisticspipes.gui

Source Code of logisticspipes.gui.GuiPowerJunction

package logisticspipes.gui;

import logisticspipes.LPConstants;
import logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity;
import logisticspipes.network.PacketHandler;
import logisticspipes.network.packets.block.PowerJunctionCheatPacket;
import logisticspipes.proxy.MainProxy;
import logisticspipes.utils.gui.BasicGuiHelper;
import logisticspipes.utils.gui.DummyContainer;
import logisticspipes.utils.gui.LogisticsBaseGuiScreen;
import logisticspipes.utils.string.StringUtil;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

public class GuiPowerJunction extends LogisticsBaseGuiScreen {
  private static final String PREFIX = "gui.powerjunction.";

  private final LogisticsPowerJunctionTileEntity junction;
 
  public GuiPowerJunction(EntityPlayer player, LogisticsPowerJunctionTileEntity junction) {
    super(176, 166, 0, 0);
    DummyContainer dummy = new DummyContainer(player, null, junction);
    dummy.addNormalSlotsForPlayerInventory(8, 80);
    this.inventorySlots = dummy;
    this.junction = junction;
  }
 
  @Override
  protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    super.drawGuiContainerForegroundLayer(par1, par2);
   
  }
 
  private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/gui/power_junction.png");

  @Override
  protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);
    int j = guiLeft;
    int k = guiTop;
    drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
    int level = 100 - junction.getChargeState();
    drawTexturedModalRect(j + 10, k + 11 + (level * 59 / 100), 176, level * 59 / 100, 5, 59 - (level * 59 / 100));
    mc.fontRenderer.drawString(StringUtil.translate(PREFIX + "LogisticsPowerJunction"), guiLeft + 30, guiTop + 8, 0x404040);
    mc.fontRenderer.drawString(StringUtil.translate(PREFIX + "StoredEnergy") + ":", guiLeft + 40, guiTop + 23, 0x404040);
    mc.fontRenderer.drawString(BasicGuiHelper.getStringWithSpacesFromInteger(junction.getPowerLevel()) + " LP", guiLeft + 40, guiTop + 33, 0x404040);
    mc.fontRenderer.drawString("/ " + BasicGuiHelper.getStringWithSpacesFromInteger(junction.MAX_STORAGE) + " LP", guiLeft + 40, guiTop + 43, 0x404040);
    mc.fontRenderer.drawString("10 RF = 5 LP", guiLeft + 24, guiTop + 58, 0x404040);
    mc.fontRenderer.drawString("1 EU = 2 LP", guiLeft + 100, guiTop + 58, 0x404040);
  }
 
  @SuppressWarnings("unchecked")
  @Override
  public void initGui() {
    super.initGui();
    this.buttonList.clear();
    if (LPConstants.DEBUG) {
      this.buttonList.add(new GuiButton(0, guiLeft + 140, guiTop + 20, 20, 20, "+"));
    }
  }
 
  @Override
  protected void actionPerformed(GuiButton par1GuiButton) {
    if(par1GuiButton.id == 0) {
      junction.addEnergy(100000);
      MainProxy.sendPacketToServer(PacketHandler.getPacket(PowerJunctionCheatPacket.class).setPosX(junction.getX()).setPosY(junction.getY()).setPosZ(junction.getZ()));
    } else {
      super.actionPerformed(par1GuiButton);   
    }
  }


}
TOP

Related Classes of logisticspipes.gui.GuiPowerJunction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.