GuiInventory .java

net.minecraft.client.gui.inventory.GuiInventory (class): members: drawEntityOnScreen, oldMouseX, oldMouseY, drawGuiContainerBackgroundLayer, updateScreen.

net.minecraft.client.gui.inventoryclass152 linesclientextends InventoryEffectRenderer5.6 KB

API Surface (7)

void updateScreen()
void initGui()
void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
void drawScreen(int mouseX, int mouseY, float partialTicks)
void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent)
void actionPerformed(GuiButton button)

Fields & Constants (2)

oldMouseX
oldMouseY

String literals (1)

"container.crafting"

Full Source

GuiInventory.java152 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui.inventory;
2
3
import java.io.IOException;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.client.gui.GuiButton;
6
import net.minecraft.client.gui.achievement.GuiAchievements;
7
import net.minecraft.client.gui.achievement.GuiStats;
8
import net.minecraft.client.renderer.GlStateManager;
9
import net.minecraft.client.renderer.InventoryEffectRenderer;
10
import net.minecraft.client.renderer.OpenGlHelper;
11
import net.minecraft.client.renderer.RenderHelper;
12
import net.minecraft.client.renderer.entity.RenderManager;
13
import net.minecraft.client.resources.I18n;
14
import net.minecraft.entity.EntityLivingBase;
15
import net.minecraft.entity.player.EntityPlayer;
16
17
public class GuiInventory extends InventoryEffectRenderer
18
{
19
    /** The old x position of the mouse pointer */
20
    private float oldMouseX;
21
22
    /** The old y position of the mouse pointer */
23
    private float oldMouseY;
24
25
    public GuiInventory(EntityPlayer p_i1094_1_)
26
    {
27
        super(p_i1094_1_.inventoryContainer);
28
        this.allowUserInput = true;
29
    }
30
31
    /**
32
     * Called from the main game loop to update the screen.
33
     */
34
    public void updateScreen()
35
    {
36
        if (this.mc.playerController.isInCreativeMode())
37
        {
38
            this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
39
        }
40
41
        this.updateActivePotionEffects();
42
    }
43
44
    /**
45
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
46
     * window resizes, the buttonList is cleared beforehand.
47
     */
48
    public void initGui()
49
    {
50
        this.buttonList.clear();
51
52
        if (this.mc.playerController.isInCreativeMode())
53
        {
54
            this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
55
        }
56
        else
57
        {
58
            super.initGui();
59
        }
60
    }
61
62
    /**
63
     * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
64
     */
65
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
66
    {
67
        this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752);
68
    }
69
70
    /**
71
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
72
     */
73
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
74
    {
75
        super.drawScreen(mouseX, mouseY, partialTicks);
76
        this.oldMouseX = (float)mouseX;
77
        this.oldMouseY = (float)mouseY;
78
    }
79
80
    /**
81
     * Args : renderPartialTicks, mouseX, mouseY
82
     */
83
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
84
    {
85
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
86
        this.mc.getTextureManager().bindTexture(inventoryBackground);
87
        int i = this.guiLeft;
88
        int j = this.guiTop;
89
        this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
90
        drawEntityOnScreen(i + 51, j + 75, 30, (float)(i + 51) - this.oldMouseX, (float)(j + 75 - 50) - this.oldMouseY, this.mc.thePlayer);
91
    }
92
93
    /**
94
     * Draws the entity to the screen. Args: xPos, yPos, scale, mouseX, mouseY, entityLiving
95
     */
96
    public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent)
97
    {
98
        GlStateManager.enableColorMaterial();
99
        GlStateManager.pushMatrix();
100
        GlStateManager.translate((float)posX, (float)posY, 50.0F);
101
        GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
102
        GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
103
        float f = ent.renderYawOffset;
104
        float f1 = ent.rotationYaw;
105
        float f2 = ent.rotationPitch;
106
        float f3 = ent.prevRotationYawHead;
107
        float f4 = ent.rotationYawHead;
108
        GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
109
        RenderHelper.enableStandardItemLighting();
110
        GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
111
        GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
112
        ent.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
113
        ent.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
114
        ent.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
115
        ent.rotationYawHead = ent.rotationYaw;
116
        ent.prevRotationYawHead = ent.rotationYaw;
117
        GlStateManager.translate(0.0F, 0.0F, 0.0F);
118
        RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
119
        rendermanager.setPlayerViewY(180.0F);
120
        rendermanager.setRenderShadow(false);
121
        rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
122
        rendermanager.setRenderShadow(true);
123
        ent.renderYawOffset = f;
124
        ent.rotationYaw = f1;
125
        ent.rotationPitch = f2;
126
        ent.prevRotationYawHead = f3;
127
        ent.rotationYawHead = f4;
128
        GlStateManager.popMatrix();
129
        RenderHelper.disableStandardItemLighting();
130
        GlStateManager.disableRescaleNormal();
131
        GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
132
        GlStateManager.disableTexture2D();
133
        GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
134
    }
135
136
    /**
137
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
138
     */
139
    protected void actionPerformed(GuiButton button) throws IOException
140
    {
141
        if (button.id == 0)
142
        {
143
            this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter()));
144
        }
145
146
        if (button.id == 1)
147
        {
148
            this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter()));
149
        }
150
    }
151
}
152

Deobfuscated MCP 1.8.9 source of GuiInventory from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/gui/inventory/GuiInventory.java), stored verbatim.