11package win .baruna .blockmeter .measurebox ;
22
3- import java .util .ArrayList ;
4- import java .util .Collections ;
5- import java .util .List ;
6-
73import com .mojang .blaze3d .systems .RenderSystem ;
8-
94import me .shedaniel .autoconfig .AutoConfig ;
105import net .minecraft .client .MinecraftClient ;
116import net .minecraft .client .font .TextRenderer ;
12- import net .minecraft .client .render .BufferBuilder ;
13- import net .minecraft .client .render .Camera ;
14- import net .minecraft .client .render .GameRenderer ;
15- import net .minecraft .client .render .Tessellator ;
16- import net .minecraft .client .render .VertexConsumerProvider ;
17- import net .minecraft .client .render .VertexFormats ;
7+ import net .minecraft .client .render .*;
188import net .minecraft .client .render .VertexFormat .DrawMode ;
199import net .minecraft .client .util .math .MatrixStack ;
2010import net .minecraft .network .PacketByteBuf ;
21- import net .minecraft .text .MutableText ;
2211import net .minecraft .text .Text ;
2312import net .minecraft .util .DyeColor ;
2413import net .minecraft .util .Identifier ;
3019import win .baruna .blockmeter .BlockMeterClient ;
3120import win .baruna .blockmeter .ModConfig ;
3221
22+ import java .util .ArrayList ;
23+ import java .util .Collections ;
24+ import java .util .List ;
25+
3326public class ClientMeasureBox extends MeasureBox {
3427 private Box box ;
3528
3629 protected ClientMeasureBox (final BlockPos blockStart , final BlockPos blockEnd , final Identifier dimension ,
37- final DyeColor color , final boolean finished , final int mode , final int orientation ) {
30+ final DyeColor color , final boolean finished , final int mode , final int orientation ) {
3831 super (blockStart , blockEnd , dimension , color , finished , mode , orientation );
3932 updateBoundingBox ();
4033 }
@@ -52,7 +45,7 @@ public static ClientMeasureBox getBox(final BlockPos block, final Identifier dim
5245
5346 /**
5447 * Sets the second box corner
55- *
48+ *
5649 * @param block second corner position
5750 */
5851 public void setBlockEnd (final BlockPos block ) {
@@ -62,7 +55,7 @@ public void setBlockEnd(final BlockPos block) {
6255
6356 /**
6457 * The current creation state of the MeasureBox
65- *
58+ *
6659 * @return true if MeasureBox is completed
6760 */
6861 public boolean isFinished () {
@@ -78,7 +71,7 @@ public void setFinished() {
7871
7972 /**
8073 * Sets the Color of the MeasureBox
81- *
74+ *
8275 * @param color Color to be applied
8376 */
8477 public void setColor (final DyeColor color ) {
@@ -87,7 +80,7 @@ public void setColor(final DyeColor color) {
8780
8881 /**
8982 * Tests if the block is on a corner of the box
90- *
83+ *
9184 * @param block Position to test
9285 * @return true if block is a corner
9386 */
@@ -100,7 +93,7 @@ public boolean isCorner(final BlockPos block) {
10093 /**
10194 * Loosens the selected Corner i.e. the opposite corner gets fixed, and the
10295 * current one can be moved
103- *
96+ *
10497 * @param block The corner to loosen, needs to be an actual corner of the box
10598 */
10699 public void loosenCorner (final BlockPos block ) {
@@ -114,7 +107,7 @@ public void loosenCorner(final BlockPos block) {
114107
115108 /**
116109 * Renders the Box
117- *
110+ *
118111 * @param camera rendering Camera
119112 * @param stack
120113 * @param currentDimension Dimension the Player currently is in
@@ -125,24 +118,23 @@ public void render(final Camera camera, final MatrixStack stack, final Identifie
125118
126119 /**
127120 * Renders the Box
128- *
121+ *
129122 * @param camera rendering Camera
130123 * @param stack
131124 * @param currentDimension Dimension the Player currently is in
132125 * @param boxCreatorName Name of the Player that created the Box
133126 */
134127 public void render (final Camera camera , final MatrixStack stack , final Identifier currentDimension ,
135- final Text boxCreatorName ) {
128+ final Text boxCreatorName ) {
136129 if (!(currentDimension .equals (this .dimension ))) {
137130 return ;
138131 }
139132 final Vec3d pos = camera .getPos ();
140133
141134 // FIXME This actually does nothing
142135 RenderSystem .lineWidth (2.0f );
143-
136+
144137 RenderSystem .disableDepthTest ();
145- RenderSystem .disableTexture ();
146138 RenderSystem .disableBlend ();
147139
148140 stack .push ();
@@ -211,7 +203,6 @@ public void render(final Camera camera, final MatrixStack stack, final Identifie
211203 tess .draw ();
212204
213205 }
214- RenderSystem .enableTexture ();
215206 RenderSystem .lineWidth (1.0f );
216207
217208 this .drawLengths (camera , stack , boxCreatorName );
@@ -239,7 +230,7 @@ private void updateBoundingBox() {
239230
240231 /**
241232 * Draws the length label
242- *
233+ *
243234 * @param camera rendering Camera
244235 * @param stack
245236 * @param boxCreatorName Name of the Box creator
@@ -317,7 +308,7 @@ private void drawLengths(final Camera camera, final MatrixStack stack, final Tex
317308
318309 /**
319310 * Draws a text with orientation and position
320- *
311+ *
321312 * @param stack
322313 * @param x
323314 * @param y
@@ -328,9 +319,8 @@ private void drawLengths(final Camera camera, final MatrixStack stack, final Tex
328319 * @param playerPos
329320 */
330321 private void drawText (final MatrixStack stack , final double x , final double y , final double z , final float yaw ,
331- final float pitch , final String text , final Vec3d playerPos ) {
332- @ SuppressWarnings ("resource" )
333- final TextRenderer textRenderer = MinecraftClient .getInstance ().textRenderer ;
322+ final float pitch , final String text , final Vec3d playerPos ) {
323+ @ SuppressWarnings ("resource" ) final TextRenderer textRenderer = MinecraftClient .getInstance ().textRenderer ;
334324
335325 final var literalText = Text .literal (text );
336326
@@ -380,7 +370,7 @@ private void drawText(final MatrixStack stack, final double x, final double y, f
380370 !conf .backgroundForLabels , // shadow
381371 model , // matrix
382372 immediate , // draw buffer
383- true , // seeThrough
373+ TextRenderer . TextLayerType . SEE_THROUGH ,
384374 0 , // backgroundColor => underlineColor,
385375 15728880 // light
386376 );
@@ -402,7 +392,7 @@ static private void incrementColor() {
402392
403393 /**
404394 * Accessor for the currently selected color
405- *
395+ *
406396 * @return currently selected color
407397 */
408398 static private DyeColor getSelectedColor () {
@@ -417,7 +407,7 @@ public static void setColorIndex(final int newColor) {
417407
418408 /**
419409 * Parses a ClientMeasureBox from a PacketByteBuf
420- *
410+ *
421411 * @param attachedData a PacketByteBuf containing the ClientMeasureBox
422412 * @return the PacketByteBuf submitted
423413 */
0 commit comments