TechReborn/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java

94 lines
3.4 KiB
Java
Raw Normal View History

package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
2016-02-21 15:16:55 +01:00
import net.minecraft.client.renderer.GlStateManager;
2016-07-23 20:10:37 +02:00
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
2016-03-13 17:08:30 +01:00
import net.minecraft.util.text.translation.I18n;
2016-07-23 20:10:37 +02:00
import net.minecraftforge.fluids.FluidStack;
import techreborn.client.container.ContainerIndustrialSawmill;
2016-07-23 20:10:37 +02:00
import techreborn.tiles.multiblock.TileIndustrialSawmill;
2016-10-08 21:46:16 +02:00
public class GuiIndustrialSawmill extends GuiContainer {
2016-03-25 10:47:34 +01:00
public static final ResourceLocation texture = new ResourceLocation("techreborn",
2016-10-08 21:46:16 +02:00
"textures/gui/industrial_sawmill.png");
2016-03-25 10:47:34 +01:00
TileIndustrialSawmill sawmill;
2016-10-08 21:46:16 +02:00
public GuiIndustrialSawmill(EntityPlayer player, TileIndustrialSawmill tilesawmill) {
2016-03-25 10:47:34 +01:00
super(new ContainerIndustrialSawmill(tilesawmill, player));
this.xSize = 176;
this.ySize = 167;
2016-10-08 21:46:16 +02:00
this.sawmill = tilesawmill;
2016-03-25 10:47:34 +01:00
}
2016-03-25 10:47:34 +01:00
@Override
2016-10-08 21:46:16 +02:00
public void initGui() {
2016-03-25 10:47:34 +01:00
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
super.initGui();
}
2016-03-25 10:47:34 +01:00
@Override
2016-10-08 21:46:16 +02:00
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
2016-03-25 10:47:34 +01:00
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
2016-07-23 20:10:37 +02:00
2016-03-25 10:47:34 +01:00
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
2016-07-23 20:10:37 +02:00
int progress = sawmill.getProgressScaled(24);
this.drawTexturedModalRect(k + 56, l + 38, 176, 14, progress - 1, 11);
2016-07-23 20:10:37 +02:00
int energy = 13 - (int) (sawmill.getEnergy() / sawmill.getMaxPower() * 13F);
drawTexturedModalRect(k + 36, l + 66 + energy, 179, 1 + energy, 7, 13 - energy);
2016-10-08 21:46:16 +02:00
if (!sawmill.tank.isEmpty()) {
2016-07-23 20:10:37 +02:00
drawFluid(sawmill.tank.getFluid(), k + 11, l + 66, 12, 47, sawmill.tank.getCapacity());
2015-06-14 20:34:52 +02:00
int j = sawmill.getEnergyScaled(12);
if (j > 0) {
this.drawTexturedModalRect(k + 33, l + 65 + 12 - j, 176, 12 - j, 14, j + 2);
}
2016-07-23 20:10:37 +02:00
if (!sawmill.getMutliBlock()) {
//GuiUtil.drawTooltipBox(k + 30, l + 50 + 12, 114, 10);
this.fontRendererObj.drawString(I18n.translateToLocal("techreborn.message.missingmultiblock"), k + 38,
2016-10-08 21:46:16 +02:00
l + 52 + 12, -1);
}
2016-03-25 10:47:34 +01:00
}
}
2016-07-23 20:10:37 +02:00
public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
ResourceLocation still = fluid.getFluid().getStill(fluid);
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(still.toString());
int drawHeight = (int) ((fluid.amount / (maxCapacity * 1F)) * height);
int iconHeight = sprite.getIconHeight();
int offsetHeight = drawHeight;
int iteration = 0;
2016-10-08 21:46:16 +02:00
while (offsetHeight != 0) {
2016-07-23 20:10:37 +02:00
int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
drawTexturedModalRect(x, y - offsetHeight, sprite, width, curHeight);
offsetHeight -= curHeight;
iteration++;
2016-10-08 21:46:16 +02:00
if (iteration > 50)
break;
2016-07-23 20:10:37 +02:00
}
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
2016-03-25 10:47:34 +01:00
String name = I18n.translateToLocal("tile.techreborn.industrialsawmill.name");
2016-07-23 20:10:37 +02:00
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 58, this.ySize - 96 + 2, 4210752);
2016-03-25 10:47:34 +01:00
}
2016-07-23 20:10:37 +02:00
}