    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.client.Minecraft;
    006    import org.lwjgl.opengl.GL11;
    007    import org.lwjgl.opengl.GL12;
    008
    009    @SideOnly(Side.CLIENT)
    010    public class GuiInventory extends InventoryEffectRenderer
    011    {
    012        /**
    013         * x size of the inventory window in pixels. Defined as float, passed as int
    014         */
    015        private float xSize_lo;
    016
    017        /**
    018         * y size of the inventory window in pixels. Defined as float, passed as int.
    019         */
    020        private float ySize_lo;
    021
    022        public GuiInventory(EntityPlayer par1EntityPlayer)
    023        {
    024            super(par1EntityPlayer.inventorySlots);
    025            this.allowUserInput = true;
    026            par1EntityPlayer.addStat(AchievementList.openInventory, 1);
    027        }
    028
    029        /**
    030         * Called from the main game loop to update the screen.
    031         */
    032        public void updateScreen()
    033        {
    034            if (this.mc.playerController.isInCreativeMode())
    035            {
    036                this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
    037            }
    038        }
    039
    040        /**
    041         * Adds the buttons (and other controls) to the screen in question.
    042         */
    043        public void initGui()
    044        {
    045            this.controlList.clear();
    046
    047            if (this.mc.playerController.isInCreativeMode())
    048            {
    049                this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
    050            }
    051            else
    052            {
    053                super.initGui();
    054            }
    055        }
    056
    057        /**
    058         * Draw the foreground layer for the GuiContainer (everything in front of the items)
    059         */
    060        protected void drawGuiContainerForegroundLayer()
    061        {
    062            this.fontRenderer.drawString(StatCollector.translateToLocal("container.crafting"), 86, 16, 4210752);
    063        }
    064
    065        /**
    066         * Draws the screen and all the components in it.
    067         */
    068        public void drawScreen(int par1, int par2, float par3)
    069        {
    070            super.drawScreen(par1, par2, par3);
    071            this.xSize_lo = (float)par1;
    072            this.ySize_lo = (float)par2;
    073        }
    074
    075        /**
    076         * Draw the background layer for the GuiContainer (everything behind the items)
    077         */
    078        protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    079        {
    080            int var4 = this.mc.renderEngine.getTexture("/gui/inventory.png");
    081            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    082            this.mc.renderEngine.bindTexture(var4);
    083            int var5 = this.guiLeft;
    084            int var6 = this.guiTop;
    085            this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
    086            func_74223_a(this.mc, var5 + 51, var6 + 75, 30, (float)(var5 + 51) - this.xSize_lo, (float)(var6 + 75 - 50) - this.ySize_lo);
    087        }
    088
    089        public static void func_74223_a(Minecraft par0Minecraft, int par1, int par2, int par3, float par4, float par5)
    090        {
    091            GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    092            GL11.glPushMatrix();
    093            GL11.glTranslatef((float)par1, (float)par2, 50.0F);
    094            GL11.glScalef((float)(-par3), (float)par3, (float)par3);
    095            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    096            float var6 = par0Minecraft.thePlayer.renderYawOffset;
    097            float var7 = par0Minecraft.thePlayer.rotationYaw;
    098            float var8 = par0Minecraft.thePlayer.rotationPitch;
    099            GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
    100            RenderHelper.enableStandardItemLighting();
    101            GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
    102            GL11.glRotatef(-((float)Math.atan((double)(par5 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
    103            par0Minecraft.thePlayer.renderYawOffset = (float)Math.atan((double)(par4 / 40.0F)) * 20.0F;
    104            par0Minecraft.thePlayer.rotationYaw = (float)Math.atan((double)(par4 / 40.0F)) * 40.0F;
    105            par0Minecraft.thePlayer.rotationPitch = -((float)Math.atan((double)(par5 / 40.0F))) * 20.0F;
    106            par0Minecraft.thePlayer.rotationYawHead = par0Minecraft.thePlayer.rotationYaw;
    107            GL11.glTranslatef(0.0F, par0Minecraft.thePlayer.yOffset, 0.0F);
    108            RenderManager.instance.playerViewY = 180.0F;
    109            RenderManager.instance.renderEntityWithPosYaw(par0Minecraft.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
    110            par0Minecraft.thePlayer.renderYawOffset = var6;
    111            par0Minecraft.thePlayer.rotationYaw = var7;
    112            par0Minecraft.thePlayer.rotationPitch = var8;
    113            GL11.glPopMatrix();
    114            RenderHelper.disableStandardItemLighting();
    115            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    116        }
    117
    118        /**
    119         * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    120         */
    121        protected void actionPerformed(GuiButton par1GuiButton)
    122        {
    123            if (par1GuiButton.id == 0)
    124            {
    125                this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter));
    126            }
    127
    128            if (par1GuiButton.id == 1)
    129            {
    130                this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter));
    131            }
    132        }
    133    }