RealmsSliderButton .java

net.minecraft.realms.RealmsSliderButton (class): members: clampSteps, maxValue, minValue, sliding, toValue, steps, toPct, getYImage, released, renderBg.

net.minecraft.realmsclass105 linescommonextends RealmsButton3.6 KB

API Surface (10)

String getMessage()
float toPct(float p_toPct_1_)
float toValue(float p_toValue_1_)
float clamp(float p_clamp_1_)
float clampSteps(float p_clampSteps_1_)
int getYImage(boolean p_getYImage_1_)
void renderBg(int p_renderBg_1_, int p_renderBg_2_)
void clicked(int p_clicked_1_, int p_clicked_2_)
void clicked(float p_clicked_1_)
void released(int p_released_1_, int p_released_2_)

Fields & Constants (5)

value
sliding
minValue
maxValue
steps

Code Graph: Dependencies (4)

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

Full Source

RealmsSliderButton.java105 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.realms;
2
3
import net.minecraft.client.Minecraft;
4
import net.minecraft.client.renderer.GlStateManager;
5
import net.minecraft.util.MathHelper;
6
7
public class RealmsSliderButton extends RealmsButton
8
{
9
    public float value;
10
    public boolean sliding;
11
    private final float minValue;
12
    private final float maxValue;
13
    private int steps;
14
15
    public RealmsSliderButton(int p_i1056_1_, int p_i1056_2_, int p_i1056_3_, int p_i1056_4_, int p_i1056_5_, int p_i1056_6_)
16
    {
17
        this(p_i1056_1_, p_i1056_2_, p_i1056_3_, p_i1056_4_, p_i1056_6_, 0, 1.0F, (float)p_i1056_5_);
18
    }
19
20
    public RealmsSliderButton(int p_i1057_1_, int p_i1057_2_, int p_i1057_3_, int p_i1057_4_, int p_i1057_5_, int p_i1057_6_, float p_i1057_7_, float p_i1057_8_)
21
    {
22
        super(p_i1057_1_, p_i1057_2_, p_i1057_3_, p_i1057_4_, 20, "");
23
        this.value = 1.0F;
24
        this.minValue = p_i1057_7_;
25
        this.maxValue = p_i1057_8_;
26
        this.value = this.toPct((float)p_i1057_6_);
27
        this.getProxy().displayString = this.getMessage();
28
    }
29
30
    public String getMessage()
31
    {
32
        return "";
33
    }
34
35
    public float toPct(float p_toPct_1_)
36
    {
37
        return MathHelper.clamp_float((this.clamp(p_toPct_1_) - this.minValue) / (this.maxValue - this.minValue), 0.0F, 1.0F);
38
    }
39
40
    public float toValue(float p_toValue_1_)
41
    {
42
        return this.clamp(this.minValue + (this.maxValue - this.minValue) * MathHelper.clamp_float(p_toValue_1_, 0.0F, 1.0F));
43
    }
44
45
    public float clamp(float p_clamp_1_)
46
    {
47
        p_clamp_1_ = this.clampSteps(p_clamp_1_);
48
        return MathHelper.clamp_float(p_clamp_1_, this.minValue, this.maxValue);
49
    }
50
51
    protected float clampSteps(float p_clampSteps_1_)
52
    {
53
        if (this.steps > 0)
54
        {
55
            p_clampSteps_1_ = (float)(this.steps * Math.round(p_clampSteps_1_ / (float)this.steps));
56
        }
57
58
        return p_clampSteps_1_;
59
    }
60
61
    public int getYImage(boolean p_getYImage_1_)
62
    {
63
        return 0;
64
    }
65
66
    public void renderBg(int p_renderBg_1_, int p_renderBg_2_)
67
    {
68
        if (this.getProxy().visible)
69
        {
70
            if (this.sliding)
71
            {
72
                this.value = (float)(p_renderBg_1_ - (this.getProxy().xPosition + 4)) / (float)(this.getProxy().getButtonWidth() - 8);
73
                this.value = MathHelper.clamp_float(this.value, 0.0F, 1.0F);
74
                float f = this.toValue(this.value);
75
                this.clicked(f);
76
                this.value = this.toPct(f);
77
                this.getProxy().displayString = this.getMessage();
78
            }
79
80
            Minecraft.getMinecraft().getTextureManager().bindTexture(WIDGETS_LOCATION);
81
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
82
            this.blit(this.getProxy().xPosition + (int)(this.value * (float)(this.getProxy().getButtonWidth() - 8)), this.getProxy().yPosition, 0, 66, 4, 20);
83
            this.blit(this.getProxy().xPosition + (int)(this.value * (float)(this.getProxy().getButtonWidth() - 8)) + 4, this.getProxy().yPosition, 196, 66, 4, 20);
84
        }
85
    }
86
87
    public void clicked(int p_clicked_1_, int p_clicked_2_)
88
    {
89
        this.value = (float)(p_clicked_1_ - (this.getProxy().xPosition + 4)) / (float)(this.getProxy().getButtonWidth() - 8);
90
        this.value = MathHelper.clamp_float(this.value, 0.0F, 1.0F);
91
        this.clicked(this.toValue(this.value));
92
        this.getProxy().displayString = this.getMessage();
93
        this.sliding = true;
94
    }
95
96
    public void clicked(float p_clicked_1_)
97
    {
98
    }
99
100
    public void released(int p_released_1_, int p_released_2_)
101
    {
102
        this.sliding = false;
103
    }
104
}
105

Deobfuscated MCP 1.8.9 source of RealmsSliderButton from Marcelektro/MavenMCP-1.8.9 (net/minecraft/realms/RealmsSliderButton.java), stored verbatim.