Skip to content

Instantly share code, notes, and snippets.

/something.java Secret

Created May 22, 2016 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2b3570c128225b2d3bde1c3031113cc1 to your computer and use it in GitHub Desktop.
Save anonymous/2b3570c128225b2d3bde1c3031113cc1 to your computer and use it in GitHub Desktop.
package com.koopamillion.gui;
import java.util.Arrays;
import org.lwjgl.opengl.GL11;
import com.koopamillion.energy.EnergyBar;
import com.koopamillion.energy.IEnergy;
import com.koopamillion.inventory.ContainerReactor;
import com.koopamillion.lib.Energy;
import com.koopamillion.lib.RefStrings;
import com.koopamillion.tile_entity.TileEntityReactor;
import com.koopamillion.util.GuiUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class GUIReactor extends GuiContainer{
public final ResourceLocation GUI = new ResourceLocation(RefStrings.MODID + ":textures/gui/container/reactor.png");
public final EntityPlayer player;
public final World world;
public final int x;
public final int y;
public final int z;
public TileEntityReactor tileentity;
public GUIReactor(EntityPlayer player, World world, int x, int y, int z){
super(new ContainerReactor(player, world, x, y, z));
this.player = player;
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.tileentity = (TileEntityReactor) world.getTileEntity(x, y, z);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y){
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:lava_still");
this.mc.getTextureManager().bindTexture(GUI);
GuiUtil.drawRectangle(guiLeft, guiTop, xSize, ySize, 256, 256, 0, 0);
int energyBarSize = 48;
this.drawTexturedModalRect(guiLeft + 80, guiTop + 7 + energyBarSize - ((IEnergy) tileentity).getEnergyBar().getEnergyLevelScaled(energyBarSize), 176, 0, 16, ((IEnergy) tileentity).getEnergyBar().getEnergyLevelScaled(energyBarSize));
this.drawTexturedModalRect(guiLeft + 55, guiTop + 7 + 48 - tileentity.heat / (int) 21, 192, 0, 16, tileentity.heat / (int) 21);
this.drawTexturedModalRect(guiLeft + 105, guiTop + 7 + 48 - tileentity.coolant / (int) 208.3333333, 208, 0, 16, tileentity.coolant / (int) 208.3333333);
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y){
float scale = 0.8f;
GL11.glScalef(scale, scale, scale);
int seconds = tileentity.getBurnTime() / (20 * tileentity.burnTimeRemovedPerTick);
int minutes = seconds / 60;
fontRendererObj.drawString(seconds + (this.tileentity.isBurning() ? 1 : 0) + " fuel", 8, 8, 4210752);
GL11.glScalef(1 / scale, 1 / scale, 1 / scale);
drawEnergyLevel(x, y);
drawHeatLevel(x, y);
drawCoolantLevel(x, y);
}
private void drawEnergyLevel(int x, int y){
int minX = guiLeft + 80;
int maxX = guiLeft + 95;
int minY = guiTop + 7;
int maxY = guiTop + 54;
EnergyBar energyBar = ((IEnergy) tileentity).getEnergyBar();
if(x >= minX && x <= maxX && y >= minY && y <= maxY){
this.drawHoveringText(Arrays.asList(energyBar.getEnergyLevel() + " /" + energyBar.getMaxEnergyLevel() + " " + Energy.Koops.getName()), x - guiLeft - 6, y - guiTop, fontRendererObj);
}
}
private void drawHeatLevel(int x, int y){
int minX = guiLeft + 55;
int maxX = guiLeft + 70;
int minY = guiTop + 7;
int maxY = guiTop + 54;
int heat = tileentity.heat;
if(x >= minX && x <= maxX && y >= minY && y <= maxY){
this.drawHoveringText(Arrays.asList(heat + " /" + "1000" + " °C"), x - guiLeft - 6, y - guiTop, fontRendererObj);
}
}
private void drawCoolantLevel(int x, int y){
int minX = guiLeft + 105;
int maxX = guiLeft + 120;
int minY = guiTop + 7;
int maxY = guiTop + 54;
int coolant = tileentity.coolant;
if(x >= minX && x <= maxX && y >= minY && y <= maxY){
this.drawHoveringText(Arrays.asList(coolant + " /" + "10000" + " mb"), x - guiLeft - 6, y - guiTop, fontRendererObj);
}
}
private void drawFluidQuad(int x, int y, int width, int height, float minU, float minV, float maxU, float maxV) {
Tessellator tessellator = Tessellator.instance;
WorldRenderer worldrenderer = tessellator.renderingWorldRenderer;
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldrenderer.pos((double)x, (double)(y + height), (double)this.zLevel).tex(minU, maxV).endVertex();
worldrenderer.pos((double)(x + width), (double)(y + height), (double)this.zLevel).tex(maxU, maxV).endVertex();
worldrenderer.pos((double)(x + width), (double)y, (double)this.zLevel).tex(maxU, minV).endVertex();
worldrenderer.pos((double)x, (double)y, (double)this.zLevel).tex(minU, minV).endVertex();
tessellator.draw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment