InventoryEffectRenderer .java

net.minecraft.client.renderer.InventoryEffectRenderer (class, 114 lines): members: hasActivePotionEffects, updateActivePotionEffects, initGui, drawScreen.

net.minecraft.client.rendererclass114 linesclientextends GuiContainer3.7 KB

API Surface (3)

void initGui()
void updateActivePotionEffects()
void drawScreen(int mouseX, int mouseY, float partialTicks)

Fields & Constants (1)

hasActivePotionEffects

String literals (3)

"enchantment.level.2"
"enchantment.level.3"
"enchantment.level.4"

Code Graph: Dependencies (8)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

InventoryEffectRenderer.java114 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer;
2
3
import java.util.Collection;
4
import net.minecraft.client.gui.inventory.GuiContainer;
5
import net.minecraft.client.resources.I18n;
6
import net.minecraft.inventory.Container;
7
import net.minecraft.potion.Potion;
8
import net.minecraft.potion.PotionEffect;
9
10
public abstract class InventoryEffectRenderer extends GuiContainer
11
{
12
    /** True if there is some potion effect to display */
13
    private boolean hasActivePotionEffects;
14
15
    public InventoryEffectRenderer(Container inventorySlotsIn)
16
    {
17
        super(inventorySlotsIn);
18
    }
19
20
    /**
21
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
22
     * window resizes, the buttonList is cleared beforehand.
23
     */
24
    public void initGui()
25
    {
26
        super.initGui();
27
        this.updateActivePotionEffects();
28
    }
29
30
    protected void updateActivePotionEffects()
31
    {
32
        if (!this.mc.thePlayer.getActivePotionEffects().isEmpty())
33
        {
34
            this.guiLeft = 160 + (this.width - this.xSize - 200) / 2;
35
            this.hasActivePotionEffects = true;
36
        }
37
        else
38
        {
39
            this.guiLeft = (this.width - this.xSize) / 2;
40
            this.hasActivePotionEffects = false;
41
        }
42
    }
43
44
    /**
45
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
46
     */
47
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
48
    {
49
        super.drawScreen(mouseX, mouseY, partialTicks);
50
51
        if (this.hasActivePotionEffects)
52
        {
53
            this.drawActivePotionEffects();
54
        }
55
    }
56
57
    /**
58
     * Display the potion effects list
59
     */
60
    private void drawActivePotionEffects()
61
    {
62
        int i = this.guiLeft - 124;
63
        int j = this.guiTop;
64
        int k = 166;
65
        Collection<PotionEffect> collection = this.mc.thePlayer.getActivePotionEffects();
66
67
        if (!collection.isEmpty())
68
        {
69
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
70
            GlStateManager.disableLighting();
71
            int l = 33;
72
73
            if (collection.size() > 5)
74
            {
75
                l = 132 / (collection.size() - 1);
76
            }
77
78
            for (PotionEffect potioneffect : this.mc.thePlayer.getActivePotionEffects())
79
            {
80
                Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
81
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
82
                this.mc.getTextureManager().bindTexture(inventoryBackground);
83
                this.drawTexturedModalRect(i, j, 0, 166, 140, 32);
84
85
                if (potion.hasStatusIcon())
86
                {
87
                    int i1 = potion.getStatusIconIndex();
88
                    this.drawTexturedModalRect(i + 6, j + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
89
                }
90
91
                String s1 = I18n.format(potion.getName(), new Object[0]);
92
93
                if (potioneffect.getAmplifier() == 1)
94
                {
95
                    s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
96
                }
97
                else if (potioneffect.getAmplifier() == 2)
98
                {
99
                    s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
100
                }
101
                else if (potioneffect.getAmplifier() == 3)
102
                {
103
                    s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
104
                }
105
106
                this.fontRendererObj.drawStringWithShadow(s1, (float)(i + 10 + 18), (float)(j + 6), 16777215);
107
                String s = Potion.getDurationString(potioneffect);
108
                this.fontRendererObj.drawStringWithShadow(s, (float)(i + 10 + 18), (float)(j + 6 + 10), 8355711);
109
                j += l;
110
            }
111
        }
112
    }
113
}
114

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