1
1
package platinpython .rgbblocks .client .gui .widget ;
2
2
3
+ import com .mojang .blaze3d .systems .RenderSystem ;
3
4
import com .mojang .blaze3d .vertex .PoseStack ;
4
5
import net .minecraft .client .Minecraft ;
5
6
import net .minecraft .client .gui .components .AbstractSliderButton ;
@@ -63,63 +64,70 @@ public void setValueInt(int value) {
63
64
}
64
65
65
66
@ Override
66
- public void renderButton (PoseStack matrixStack , int mouseX , int mouseY , float partialTicks ) {
67
+ public void renderWidget (PoseStack poseStack , int mouseX , int mouseY , float partialTicks ) {
67
68
if (this .visible ) {
68
69
Minecraft minecraft = Minecraft .getInstance ();
69
- fill (matrixStack , this .getX (), this .getY (), this .getX () + this .width , this .getY () + this .height , 0xFF000000 );
70
+ fill (poseStack , this .getX (), this .getY (), this .getX () + this .width , this .getY () + this .height , 0xFF000000 );
70
71
if (minecraft .screen instanceof ColorSelectScreen ) {
71
72
ColorSelectScreen screen = (ColorSelectScreen ) minecraft .screen ;
72
73
switch (type ) {
73
74
case RED :
74
- renderRedBackground (matrixStack , screen );
75
+ renderRedBackground (poseStack , screen );
75
76
break ;
76
77
case GREEN :
77
- renderGreenBackground (matrixStack , screen );
78
+ renderGreenBackground (poseStack , screen );
78
79
break ;
79
80
case BLUE :
80
- renderBlueBackground (matrixStack , screen );
81
+ renderBlueBackground (poseStack , screen );
81
82
break ;
82
83
case HUE :
83
- renderHueBackground (matrixStack , screen );
84
+ renderHueBackground (poseStack , screen );
84
85
break ;
85
86
case SATURATION :
86
- renderSaturationBackground (matrixStack , screen );
87
+ renderSaturationBackground (poseStack , screen );
87
88
break ;
88
89
case BRIGHTNESS :
89
- renderBrightnessBackground (matrixStack , screen );
90
+ renderBrightnessBackground (poseStack , screen );
90
91
break ;
91
92
}
92
93
}
93
94
94
- this .renderBg (matrixStack , minecraft , mouseX , mouseY );
95
+ RenderSystem .setShaderTexture (0 , SLIDER_LOCATION );
96
+ RenderSystem .setShaderColor (1.0F , 1.0F , 1.0F , this .alpha );
97
+ RenderSystem .enableBlend ();
98
+ RenderSystem .defaultBlendFunc ();
99
+ RenderSystem .enableDepthTest ();
100
+ AbstractSliderButton .blitNineSliced (poseStack , this .getX () + (int ) (this .value * (double ) (this .width - 8 )),
101
+ this .getY (), 8 , 20 , 20 , 4 , 200 , 20 , 0 , this .getHandleTextureY ()
102
+ );
95
103
96
- drawCenteredString (matrixStack , minecraft .font , this .getMessage (), this .getX () + this .width / 2 ,
97
- this .getY () - ( this .height ) / 10 * 7 , getFGColor ()
104
+ drawCenteredString (poseStack , minecraft .font , this .getMessage (), this .getX () + this .width / 2 ,
105
+ this .getY () - this .height / 10 * 7 , getFGColor ()
98
106
);
99
107
}
100
108
}
101
109
102
110
private void renderRedBackground (PoseStack matrixStack , ColorSelectScreen screen ) {
103
111
int leftColor = new Color (0x00 , screen .greenSlider .getValueInt (), screen .blueSlider .getValueInt ()).getRGB ();
104
112
int rightColor = new Color (0xFF , screen .greenSlider .getValueInt (), screen .blueSlider .getValueInt ()).getRGB ();
105
- ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 , this . getY () + this . height - 1 ,
106
- leftColor , rightColor , this .getBlitOffset ()
113
+ ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 ,
114
+ this .getY () + this . height - 1 , leftColor , rightColor
107
115
);
108
116
}
109
117
110
118
private void renderGreenBackground (PoseStack matrixStack , ColorSelectScreen screen ) {
111
119
int leftColor = new Color (screen .redSlider .getValueInt (), 0x00 , screen .blueSlider .getValueInt ()).getRGB ();
112
120
int rightColor = new Color (screen .redSlider .getValueInt (), 0xFF , screen .blueSlider .getValueInt ()).getRGB ();
113
- ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 , this . getY () + this . height - 1 ,
114
- leftColor , rightColor , this .getBlitOffset ()
121
+ ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 ,
122
+ this .getY () + this . height - 1 , leftColor , rightColor
115
123
);
116
124
}
117
125
118
126
private void renderBlueBackground (PoseStack matrixStack , ColorSelectScreen screen ) {
119
127
int leftColor = new Color (screen .redSlider .getValueInt (), screen .greenSlider .getValueInt (), 0x00 ).getRGB ();
120
128
int rightColor = new Color (screen .redSlider .getValueInt (), screen .greenSlider .getValueInt (), 0xFF ).getRGB ();
121
- ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 , this . getY () + this . height - 1 ,
122
- leftColor , rightColor , this .getBlitOffset ()
129
+ ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 ,
130
+ this .getY () + this . height - 1 , leftColor , rightColor
123
131
);
124
132
}
125
133
@@ -130,23 +138,23 @@ private void renderHueBackground(PoseStack matrixStack, ColorSelectScreen screen
130
138
(float ) (screen .saturationSlider .getValueInt () / ColorSelectScreen .MAX_VALUE_SB ),
131
139
(float ) (screen .brightnessSlider .getValueInt () / ColorSelectScreen .MAX_VALUE_SB )
132
140
);
133
- ScreenUtils .fillGradient (matrixStack , lerp .apply (0 ), this .getY () + 1 , lerp .apply (17 ), this . getY () + this . height - 1 ,
134
- color . apply ( 0 ) , color .apply (17 ), this . getBlitOffset ( )
141
+ ScreenUtils .fillGradient (matrixStack , lerp .apply (0 ), this .getY () + 1 , lerp .apply (17 ),
142
+ this . getY () + this . height - 1 , color .apply (0 ), color . apply ( 17 )
135
143
);
136
- ScreenUtils .fillGradient (matrixStack , lerp .apply (17 ), this .getY () + 1 , lerp .apply (34 ), this . getY () + this . height - 1 ,
137
- color . apply ( 17 ) , color .apply (34 ), this . getBlitOffset ( )
144
+ ScreenUtils .fillGradient (matrixStack , lerp .apply (17 ), this .getY () + 1 , lerp .apply (34 ),
145
+ this . getY () + this . height - 1 , color .apply (17 ), color . apply ( 34 )
138
146
);
139
- ScreenUtils .fillGradient (matrixStack , lerp .apply (34 ), this .getY () + 1 , lerp .apply (50 ), this . getY () + this . height - 1 ,
140
- color . apply ( 34 ) , color .apply (50 ), this . getBlitOffset ( )
147
+ ScreenUtils .fillGradient (matrixStack , lerp .apply (34 ), this .getY () + 1 , lerp .apply (50 ),
148
+ this . getY () + this . height - 1 , color .apply (34 ), color . apply ( 50 )
141
149
);
142
- ScreenUtils .fillGradient (matrixStack , lerp .apply (50 ), this .getY () + 1 , lerp .apply (66 ), this . getY () + this . height - 1 ,
143
- color . apply ( 50 ) , color .apply (66 ), this . getBlitOffset ( )
150
+ ScreenUtils .fillGradient (matrixStack , lerp .apply (50 ), this .getY () + 1 , lerp .apply (66 ),
151
+ this . getY () + this . height - 1 , color .apply (50 ), color . apply ( 66 )
144
152
);
145
- ScreenUtils .fillGradient (matrixStack , lerp .apply (66 ), this .getY () + 1 , lerp .apply (82 ), this . getY () + this . height - 1 ,
146
- color . apply ( 66 ) , color .apply (82 ), this . getBlitOffset ( )
153
+ ScreenUtils .fillGradient (matrixStack , lerp .apply (66 ), this .getY () + 1 , lerp .apply (82 ),
154
+ this . getY () + this . height - 1 , color .apply (66 ), color . apply ( 82 )
147
155
);
148
- ScreenUtils .fillGradient (matrixStack , lerp .apply (82 ), this .getY () + 1 , lerp .apply (100 ), this . getY () + this . height - 1 ,
149
- color . apply ( 82 ) , color .apply (100 ), this . getBlitOffset ( )
156
+ ScreenUtils .fillGradient (matrixStack , lerp .apply (82 ), this .getY () + 1 , lerp .apply (100 ),
157
+ this . getY () + this . height - 1 , color .apply (82 ), color . apply ( 100 )
150
158
);
151
159
}
152
160
@@ -157,8 +165,8 @@ private void renderSaturationBackground(PoseStack matrixStack, ColorSelectScreen
157
165
int rightColor = Color .HSBtoRGB ((float ) (screen .hueSlider .getValue () / ColorSelectScreen .MAX_VALUE_HUE ), 1.0f ,
158
166
(float ) (screen .brightnessSlider .getValue () / ColorSelectScreen .MAX_VALUE_SB )
159
167
);
160
- ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 , this . getY () + this . height - 1 ,
161
- leftColor , rightColor , this .getBlitOffset ()
168
+ ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 ,
169
+ this .getY () + this . height - 1 , leftColor , rightColor
162
170
);
163
171
}
164
172
@@ -171,8 +179,8 @@ private void renderBrightnessBackground(PoseStack matrixStack, ColorSelectScreen
171
179
(float ) (screen .saturationSlider .getValue () / ColorSelectScreen .MAX_VALUE_SB ),
172
180
1.0f
173
181
);
174
- ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 , this . getY () + this . height - 1 ,
175
- leftColor , rightColor , this .getBlitOffset ()
182
+ ScreenUtils .fillGradient (matrixStack , this .getX () + 1 , this .getY () + 1 , this .getX () + this .width - 1 ,
183
+ this .getY () + this . height - 1 , leftColor , rightColor
176
184
);
177
185
}
178
186
}
0 commit comments