Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.TechDweebGaming.MystTech.client.gui;
- import java.util.List;
- import net.minecraft.client.gui.inventory.GuiContainer;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.StatCollector;
- import com.TechDweebGaming.MystTech.gui.ContainerCompressor;
- import com.TechDweebGaming.MystTech.reference.Reference;
- import com.TechDweebGaming.MystTech.tileentity.CompressorTileEntity;
- import com.google.common.collect.Lists;
- public class GuiCompressor extends GuiContainer {
- private IInventory playerInv;
- private CompressorTileEntity te;
- //Power Things
- private static final int bar1x = 1;
- private static final int bar2x = 17;
- private static final int barWidth = 14;
- private static final int barHeight = 42;
- public GuiCompressor(IInventory playerInv, CompressorTileEntity te) {
- super(new ContainerCompressor(playerInv, te));
- this.playerInv = playerInv;
- this.te = te;
- this.xSize = 175;
- this.ySize = 165;
- }
- @Override
- protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
- GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
- this.mc.getTextureManager().bindTexture(new ResourceLocation("mysttech:textures/gui/Compressor.png"));
- this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
- //Energy Bar
- int x = (width - xSize) / 2;
- drawEnergyBar(x + xSize - 14 - 8, 7 + 20, te.getPowerLevel(), te.EnergyLimit);
- }
- @Override
- protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
- String s = this.te.getDisplayName().getUnformattedText();
- this.fontRendererObj.drawString(s, 82 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
- this.fontRendererObj.drawString(this.playerInv.getDisplayName().getUnformattedText(), 8, 72, 4210752);
- //Bar Tool-Tip
- drawBarTooltip(mouseX, mouseY, xSize - 14 - 8, 20);
- }
- private void drawEnergyBar(int x, int y, int powerLevel, int powerLimit) {
- int bar2height = 1 + powerLevel * (barHeight - 2) / powerLimit;
- int bar1height = barHeight - bar2height;
- mc.renderEngine.bindTexture(new ResourceLocation("mysttech:/textures/gui/Energy.png"));
- drawModalRectWithCustomSizedTexture(x, y, bar1x, 0, barWidth, bar1height, 32, 64);
- drawModalRectWithCustomSizedTexture(x, y + bar1height, bar2x, bar1height, barWidth, bar2height, 32, 64);
- }
- private void drawBarTooltip(int mx, int my, int ox, int oy){
- int x = (width - xSize) / 2;
- int y = (height - ySize) / 2;
- int rx = mx - ox - x;
- int ry = my - oy - y;
- if (rx < 0 || ry < 0 || rx > barWidth || ry > barHeight)
- return;
- List<String> tooltip = Lists.newArrayList();
- tooltip.add(StatCollector.translateToLocal("text." + Reference.MOD_ID + ".compressor.energy.label"));
- tooltip.add(String.format("%d / %d RF", te.getPowerLevel(), te.EnergyLimit));
- drawHoveringText(tooltip, mx - x, my - y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement