GuiSimpleScrolledSelectionListProxy .java

net.minecraft.client.gui.GuiSimpleScrolledSelectionListProxy (class, 158 lines): members: field_178050_u, getMouseX, getMouseY, getContentHeight, drawSlot.

net.minecraft.client.guiclass158 linesclientextends GuiSlot6.1 KB

API Surface (12)

int getSize()
void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
boolean isSelected(int slotIndex)
void drawBackground()
void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
int getWidth()
int getMouseY()
int getMouseX()
int getContentHeight()
int getScrollBarX()
void handleMouseInput()
void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_)

Fields & Constants (1)

field_178050_u

Full Source

GuiSimpleScrolledSelectionListProxy.java158 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import net.minecraft.client.Minecraft;
4
import net.minecraft.client.renderer.GlStateManager;
5
import net.minecraft.client.renderer.Tessellator;
6
import net.minecraft.client.renderer.WorldRenderer;
7
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
8
import net.minecraft.realms.RealmsSimpleScrolledSelectionList;
9
import net.minecraft.util.MathHelper;
10
11
public class GuiSimpleScrolledSelectionListProxy extends GuiSlot
12
{
13
    private final RealmsSimpleScrolledSelectionList field_178050_u;
14
15
    public GuiSimpleScrolledSelectionListProxy(RealmsSimpleScrolledSelectionList p_i45525_1_, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
16
    {
17
        super(Minecraft.getMinecraft(), widthIn, heightIn, topIn, bottomIn, slotHeightIn);
18
        this.field_178050_u = p_i45525_1_;
19
    }
20
21
    protected int getSize()
22
    {
23
        return this.field_178050_u.getItemCount();
24
    }
25
26
    /**
27
     * The element in the slot that was clicked, boolean for whether it was double clicked or not
28
     */
29
    protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
30
    {
31
        this.field_178050_u.selectItem(slotIndex, isDoubleClick, mouseX, mouseY);
32
    }
33
34
    /**
35
     * Returns true if the element passed in is currently selected
36
     */
37
    protected boolean isSelected(int slotIndex)
38
    {
39
        return this.field_178050_u.isSelectedItem(slotIndex);
40
    }
41
42
    protected void drawBackground()
43
    {
44
        this.field_178050_u.renderBackground();
45
    }
46
47
    protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
48
    {
49
        this.field_178050_u.renderItem(entryID, p_180791_2_, p_180791_3_, p_180791_4_, mouseXIn, mouseYIn);
50
    }
51
52
    public int getWidth()
53
    {
54
        return super.width;
55
    }
56
57
    public int getMouseY()
58
    {
59
        return super.mouseY;
60
    }
61
62
    public int getMouseX()
63
    {
64
        return super.mouseX;
65
    }
66
67
    /**
68
     * Return the height of the content being scrolled
69
     */
70
    protected int getContentHeight()
71
    {
72
        return this.field_178050_u.getMaxPosition();
73
    }
74
75
    protected int getScrollBarX()
76
    {
77
        return this.field_178050_u.getScrollbarPosition();
78
    }
79
80
    public void handleMouseInput()
81
    {
82
        super.handleMouseInput();
83
    }
84
85
    public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_)
86
    {
87
        if (this.field_178041_q)
88
        {
89
            this.mouseX = mouseXIn;
90
            this.mouseY = mouseYIn;
91
            this.drawBackground();
92
            int i = this.getScrollBarX();
93
            int j = i + 6;
94
            this.bindAmountScrolled();
95
            GlStateManager.disableLighting();
96
            GlStateManager.disableFog();
97
            Tessellator tessellator = Tessellator.getInstance();
98
            WorldRenderer worldrenderer = tessellator.getWorldRenderer();
99
            int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
100
            int l = this.top + 4 - (int)this.amountScrolled;
101
102
            if (this.hasListHeader)
103
            {
104
                this.drawListHeader(k, l, tessellator);
105
            }
106
107
            this.drawSelectionBox(k, l, mouseXIn, mouseYIn);
108
            GlStateManager.disableDepth();
109
            int i1 = 4;
110
            this.overlayBackground(0, this.top, 255, 255);
111
            this.overlayBackground(this.bottom, this.height, 255, 255);
112
            GlStateManager.enableBlend();
113
            GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
114
            GlStateManager.disableAlpha();
115
            GlStateManager.shadeModel(7425);
116
            GlStateManager.disableTexture2D();
117
            int j1 = this.func_148135_f();
118
119
            if (j1 > 0)
120
            {
121
                int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
122
                k1 = MathHelper.clamp_int(k1, 32, this.bottom - this.top - 8);
123
                int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;
124
125
                if (l1 < this.top)
126
                {
127
                    l1 = this.top;
128
                }
129
130
                worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
131
                worldrenderer.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
132
                worldrenderer.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
133
                worldrenderer.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
134
                worldrenderer.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
135
                tessellator.draw();
136
                worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
137
                worldrenderer.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
138
                worldrenderer.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
139
                worldrenderer.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
140
                worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
141
                tessellator.draw();
142
                worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
143
                worldrenderer.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
144
                worldrenderer.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
145
                worldrenderer.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
146
                worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
147
                tessellator.draw();
148
            }
149
150
            this.func_148142_b(mouseXIn, mouseYIn);
151
            GlStateManager.enableTexture2D();
152
            GlStateManager.shadeModel(7424);
153
            GlStateManager.enableAlpha();
154
            GlStateManager.disableBlend();
155
        }
156
    }
157
}
158

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