Java tutorial
package com.savageboy74.savagetech.gui; /* * GuiLootBag.java * Copyright (C) 2014 Savage - github.com/savageboy74 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ import com.savageboy74.savagetech.container.ContainerLootBag; import com.savageboy74.savagetech.inventory.InventoryLootBag; import com.savageboy74.savagetech.util.LogHelper; import com.savageboy74.savagetech.util.NBTHelper; import com.savageboy74.savagetech.util.Strings; import com.savageboy74.savagetech.util.Textures; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; public class GuiLootBag extends GuiContainer { private final ItemStack parentItemStack; private final InventoryLootBag inventoryLootBag; public GuiLootBag(EntityPlayer entityPlayer, InventoryLootBag inventoryLootBag) { super(new ContainerLootBag(entityPlayer, inventoryLootBag)); this.parentItemStack = inventoryLootBag.parentItemStack; this.inventoryLootBag = inventoryLootBag; this.xSize = 248; this.ySize = 256; } @Override protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Textures.Gui.LOOT_BAG); int xStart = (width - xSize) / 2; int yStart = (height - ySize) / 2; this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize); } @Override public void onGuiClosed() { super.onGuiClosed(); if (mc.thePlayer != null) { for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory) { if (itemStack != null) { if (NBTHelper.hasTag(itemStack, Strings.NBT.LOOT_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Strings.NBT.LOOT_BAG_GUI_OPEN); } } } } } }