22
33import com .cleanroommc .modularui .drawable .text .TextRenderer ;
44import com .cleanroommc .modularui .utils .Color ;
5+ import com .cleanroommc .modularui .utils .Platform ;
56
6- import net .minecraft .client .renderer .BufferBuilder ;
77import net .minecraft .client .renderer .GlStateManager ;
8- import net .minecraft .client .renderer .Tessellator ;
9- import net .minecraft .client .renderer .vertex .DefaultVertexFormats ;
108import net .minecraftforge .fml .relauncher .Side ;
119import net .minecraftforge .fml .relauncher .SideOnly ;
1210
@@ -139,19 +137,10 @@ public void drawMarked(float y0, float x0, float x1) {
139137 float alpha = Color .getAlphaF (this .markedColor );
140138 if (alpha == 0 )
141139 alpha = 1f ;
142- Tessellator tessellator = Tessellator .getInstance ();
143- BufferBuilder bufferbuilder = tessellator .getBuffer ();
144- GlStateManager .color (red , green , blue , alpha );
145- GlStateManager .disableTexture2D ();
146- bufferbuilder .begin (7 , DefaultVertexFormats .POSITION );
147- bufferbuilder .pos (x0 , y1 , 0.0D ).endVertex ();
148- bufferbuilder .pos (x1 , y1 , 0.0D ).endVertex ();
149- bufferbuilder .pos (x1 , y0 , 0.0D ).endVertex ();
150- bufferbuilder .pos (x0 , y0 , 0.0D ).endVertex ();
151- tessellator .draw ();
152- GlStateManager .disableColorLogic ();
153- GlStateManager .enableTexture2D ();
154- GlStateManager .color (1 , 1 , 1 , 1 );
140+ GlStateManager .pushMatrix ();
141+ GlStateManager .scale (this .scale , this .scale , 0 );
142+ drawRect (x0 , y0 , x1 , y1 , red , green , blue , alpha );
143+ GlStateManager .popMatrix ();
155144 }
156145
157146 @ SideOnly (Side .CLIENT )
@@ -166,22 +155,21 @@ private void drawCursor(float x0, float y0) {
166155 float alpha = Color .getAlphaF (this .cursorColor );
167156 if (alpha == 0 )
168157 alpha = 1f ;
169- Tessellator tessellator = Tessellator .getInstance ();
170- BufferBuilder bufferbuilder = tessellator .getBuffer ();
171- GlStateManager .disableBlend ();
172158 GlStateManager .pushMatrix ();
173159 GlStateManager .scale (this .scale , this .scale , 0 );
160+ drawRect (x0 , y0 , x1 , y1 , red , green , blue , alpha );
161+ GlStateManager .popMatrix ();
162+ }
163+
164+ private static void drawRect (float x0 , float y0 , float x1 , float y1 , float red , float green , float blue , float alpha ) {
165+ Platform .setupDrawColor ();
174166 GlStateManager .color (red , green , blue , alpha );
175- GlStateManager .disableTexture2D ();
176- bufferbuilder .begin (7 , DefaultVertexFormats .POSITION );
177- bufferbuilder .pos (x0 , y1 , 0.0D ).endVertex ();
178- bufferbuilder .pos (x1 , y1 , 0.0D ).endVertex ();
179- bufferbuilder .pos (x1 , y0 , 0.0D ).endVertex ();
180- bufferbuilder .pos (x0 , y0 , 0.0D ).endVertex ();
181- tessellator .draw ();
167+ Platform .startDrawing (Platform .DrawMode .QUADS , Platform .VertexFormat .POS , bufferBuilder -> {
168+ bufferBuilder .pos (x0 , y1 , 0.0D ).endVertex ();
169+ bufferBuilder .pos (x1 , y1 , 0.0D ).endVertex ();
170+ bufferBuilder .pos (x1 , y0 , 0.0D ).endVertex ();
171+ bufferBuilder .pos (x0 , y0 , 0.0D ).endVertex ();
172+ });
182173 GlStateManager .color (1 , 1 , 1 , 1 );
183- GlStateManager .enableTexture2D ();
184- GlStateManager .popMatrix ();
185- GlStateManager .enableBlend ();
186174 }
187175}
0 commit comments