Package bcut

Source Code of bcut.GuiCooledCombustionEngine

package bcut;

import org.lwjgl.opengl.GL11;

import net.minecraft.src.Block;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.Item;
import net.minecraftforge.client.ForgeHooksClient;
import buildcraft.core.utils.StringUtil;
import buildcraft.energy.TileEngine;
import buildcraft.energy.gui.ContainerEngine;
import buildcraft.energy.gui.GuiEngine;

public class GuiCooledCombustionEngine extends GuiEngine {

  public GuiCooledCombustionEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
    super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
  }

 
  @Override
  protected void drawGuiContainerForegroundLayer() {
    super.drawGuiContainerForegroundLayer();
    String title = "Cooled combustion engine";
    fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
    fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
  }

  @Override
  protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    int i = mc.renderEngine.getTexture("/gfx/cooled_combustion_engine_gui.png");
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(i);
    int j = (width - xSize) / 2;
    int k = (height - ySize) / 2;
    drawTexturedModalRect(j, k, 0, 0, xSize, ySize);

    TileEngine engine = (TileEngine) tile;
    EngineCooledCombustion engineCooled = ((EngineCooledCombustion) engine.engine);

    if (engine.getScaledBurnTime(58) > 0)
      displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engineCooled.liquidId);

  }
 
 
  private void displayGauge(int j, int k, int line, int col, int squaled, int liquidId) {
    int liquidImgIndex = 0;

    if (liquidId < Block.blocksList.length && Block.blocksList[liquidId] != null) {
      ForgeHooksClient.bindTexture(Block.blocksList[liquidId].getTextureFile(), 0);
      liquidImgIndex = Block.blocksList[liquidId].blockIndexInTexture;
    } else if (Item.itemsList[liquidId] != null) {
      ForgeHooksClient.bindTexture(Item.itemsList[liquidId].getTextureFile(), 0);
      liquidImgIndex = Item.itemsList[liquidId].getIconFromDamage(0);
    } else {
      return;     
    }

    int imgLine = liquidImgIndex / 16;
    int imgColumn = liquidImgIndex - imgLine * 16;

    int start = 0;

    while (true) {
      int x = 0;

      if (squaled > 16) {
        x = 16;
        squaled -= 16;
      } else {
        x = squaled;
        squaled = 0;
      }

      drawTexturedModalRect(j + col, k + line + 58 - x - start, imgColumn * 16, imgLine * 16 + (16 - x), 16, 16 - (16 - x));
      start = start + 16;

      if (x == 0 || squaled == 0)
        break;
    }

    int i = mc.renderEngine.getTexture("/gfx/cooled_combustion_engine_gui.png");

    mc.renderEngine.bindTexture(i);
    drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
  }

}
TOP

Related Classes of bcut.GuiCooledCombustionEngine

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.