Java tutorial
/* Copyright 2015 Matthew Rogers "BossLetsPlays" * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.redthirddivision.mc.waffle.gui; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.redthirddivision.mc.waffle.containers.ContainerWaffleIron; import com.redthirddivision.mc.waffle.tileentities.TileEntityWaffleIron; /** * <strong>Project:</strong> WaffleMod <br> * <strong>File:</strong> GuiWaffleIron.java * * @author <a href = "http://redthirddivision.com/team/blp"> Matthew Rogers</a> */ @SideOnly(Side.CLIENT) public class GuiWaffleIron extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation("waffle:textures/gui/waffleIron.png"); private TileEntityWaffleIron tileentity; public GuiWaffleIron(InventoryPlayer invPlayer, TileEntityWaffleIron te) { super(new ContainerWaffleIron(invPlayer, te)); this.tileentity = te; } @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String s = this.tileentity.hasCustomInventoryName() ? this.tileentity.getInventoryName() : I18n.format(this.tileentity.getInventoryName(), new Object[0]); this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(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; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); if (this.tileentity.itemTime < 200) { int bar = (200 - this.tileentity.itemTime) * 24 / 200; this.drawTexturedModalRect(k + 79, l + 34, 176, 14, bar + 1, 16); } } }