11package platinpython .rgbblocks .client .gui .widget ;
22
3+ import com .mojang .blaze3d .systems .RenderSystem ;
34import com .mojang .blaze3d .vertex .PoseStack ;
45import net .minecraft .client .Minecraft ;
56import net .minecraft .client .gui .components .AbstractSliderButton ;
@@ -63,63 +64,70 @@ public void setValueInt(int value) {
6364 }
6465
6566 @ 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 ) {
6768 if (this .visible ) {
6869 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 );
7071 if (minecraft .screen instanceof ColorSelectScreen ) {
7172 ColorSelectScreen screen = (ColorSelectScreen ) minecraft .screen ;
7273 switch (type ) {
7374 case RED :
74- renderRedBackground (matrixStack , screen );
75+ renderRedBackground (poseStack , screen );
7576 break ;
7677 case GREEN :
77- renderGreenBackground (matrixStack , screen );
78+ renderGreenBackground (poseStack , screen );
7879 break ;
7980 case BLUE :
80- renderBlueBackground (matrixStack , screen );
81+ renderBlueBackground (poseStack , screen );
8182 break ;
8283 case HUE :
83- renderHueBackground (matrixStack , screen );
84+ renderHueBackground (poseStack , screen );
8485 break ;
8586 case SATURATION :
86- renderSaturationBackground (matrixStack , screen );
87+ renderSaturationBackground (poseStack , screen );
8788 break ;
8889 case BRIGHTNESS :
89- renderBrightnessBackground (matrixStack , screen );
90+ renderBrightnessBackground (poseStack , screen );
9091 break ;
9192 }
9293 }
9394
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+ );
95103
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 ()
98106 );
99107 }
100108 }
101109
102110 private void renderRedBackground (PoseStack matrixStack , ColorSelectScreen screen ) {
103111 int leftColor = new Color (0x00 , screen .greenSlider .getValueInt (), screen .blueSlider .getValueInt ()).getRGB ();
104112 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
107115 );
108116 }
109117
110118 private void renderGreenBackground (PoseStack matrixStack , ColorSelectScreen screen ) {
111119 int leftColor = new Color (screen .redSlider .getValueInt (), 0x00 , screen .blueSlider .getValueInt ()).getRGB ();
112120 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
115123 );
116124 }
117125
118126 private void renderBlueBackground (PoseStack matrixStack , ColorSelectScreen screen ) {
119127 int leftColor = new Color (screen .redSlider .getValueInt (), screen .greenSlider .getValueInt (), 0x00 ).getRGB ();
120128 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
123131 );
124132 }
125133
@@ -130,23 +138,23 @@ private void renderHueBackground(PoseStack matrixStack, ColorSelectScreen screen
130138 (float ) (screen .saturationSlider .getValueInt () / ColorSelectScreen .MAX_VALUE_SB ),
131139 (float ) (screen .brightnessSlider .getValueInt () / ColorSelectScreen .MAX_VALUE_SB )
132140 );
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 )
135143 );
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 )
138146 );
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 )
141149 );
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 )
144152 );
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 )
147155 );
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 )
150158 );
151159 }
152160
@@ -157,8 +165,8 @@ private void renderSaturationBackground(PoseStack matrixStack, ColorSelectScreen
157165 int rightColor = Color .HSBtoRGB ((float ) (screen .hueSlider .getValue () / ColorSelectScreen .MAX_VALUE_HUE ), 1.0f ,
158166 (float ) (screen .brightnessSlider .getValue () / ColorSelectScreen .MAX_VALUE_SB )
159167 );
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
162170 );
163171 }
164172
@@ -171,8 +179,8 @@ private void renderBrightnessBackground(PoseStack matrixStack, ColorSelectScreen
171179 (float ) (screen .saturationSlider .getValue () / ColorSelectScreen .MAX_VALUE_SB ),
172180 1.0f
173181 );
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
176184 );
177185 }
178186}
0 commit comments