package net.minecraft.client.gui.inventory;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.achievement.GuiAchievements;
import net.minecraft.client.gui.achievement.GuiStats;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
public class GuiInventory extends InventoryEffectRenderer
{
/** The old x position of the mouse pointer */
private float oldMouseX;
/** The old y position of the mouse pointer */
private float oldMouseY;
private static final String __OBFID = "CL_00000761";
public GuiInventory(EntityPlayer p_i1094_1_)
{
super(p_i1094_1_.inventoryContainer);
this.allowUserInput = true;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
if (this.mc.playerController.isInCreativeMode())
{
this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
}
this.func_175378_g();
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
this.buttonList.clear();
if (this.mc.playerController.isInCreativeMode())
{
this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
}
else
{
super.initGui();
}
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
*/
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752);
}
/**
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
super.drawScreen(mouseX, mouseY, partialTicks);
this.oldMouseX = (float)mouseX;
this.oldMouseY = (float)mouseY;
}
/**
* Args : renderPartialTicks, mouseX, mouseY
*/
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(inventoryBackground);
int var4 = this.guiLeft;
int var5 = this.guiTop;
this.drawTexturedModalRect(var4, var5, 0, 0, this.xSize, this.ySize);
drawEntityOnScreen(var4 + 51, var5 + 75, 30, (float)(var4 + 51) - this.oldMouseX, (float)(var5 + 75 - 50) - this.oldMouseY, this.mc.thePlayer);
}
/**
* Draws the entity to the screen. Args: xPos, yPos, scale, mouseX, mouseY, entityLiving
*/
public static void drawEntityOnScreen(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_)
{
GlStateManager.enableColorMaterial();
GlStateManager.pushMatrix();
GlStateManager.translate((float)p_147046_0_, (float)p_147046_1_, 50.0F);
GlStateManager.scale((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
float var6 = p_147046_5_.renderYawOffset;
float var7 = p_147046_5_.rotationYaw;
float var8 = p_147046_5_.rotationPitch;
float var9 = p_147046_5_.prevRotationYawHead;
float var10 = p_147046_5_.rotationYawHead;
GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F;
p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F;
p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F;
p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw;
p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw;
GlStateManager.translate(0.0F, 0.0F, 0.0F);
RenderManager var11 = Minecraft.getMinecraft().getRenderManager();
var11.func_178631_a(180.0F);
var11.func_178633_a(false);
var11.renderEntityWithPosYaw(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
var11.func_178633_a(true);
p_147046_5_.renderYawOffset = var6;
p_147046_5_.rotationYaw = var7;
p_147046_5_.rotationPitch = var8;
p_147046_5_.prevRotationYawHead = var9;
p_147046_5_.rotationYawHead = var10;
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.func_179090_x();
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 0)
{
this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter()));
}
if (button.id == 1)
{
this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter()));
}
}
}