@@ -38,6 +38,10 @@ public enum RenderUtils
3838{
3939 ;
4040
41+ private static final float DEFAULT_LINE_WIDTH = 2F ;
42+ private static final double MIN_LINE_WIDTH = 0.5 ;
43+ private static final double MAX_LINE_WIDTH = 20 ;
44+
4145 public static void applyRegionalRenderOffset (PoseStack matrixStack )
4246 {
4347 applyRegionalRenderOffset (matrixStack , getCameraRegion ());
@@ -153,7 +157,8 @@ public static void drawLine(PoseStack matrices, Vec3 start, Vec3 end,
153157 VertexConsumer buffer = vcp .getBuffer (layer );
154158
155159 Vec3 offset = getCameraPos ().reverse ();
156- drawLine (matrices , buffer , start .add (offset ), end .add (offset ), color );
160+ drawLine (matrices , buffer , start .add (offset ), end .add (offset ), color ,
161+ DEFAULT_LINE_WIDTH );
157162
158163 vcp .endBatch (layer );
159164 }
@@ -184,7 +189,8 @@ public static void drawTracer(PoseStack matrices, float partialTicks,
184189
185190 Vec3 start = getTracerOrigin (partialTicks );
186191 Vec3 offset = getCameraPos ().reverse ();
187- drawLine (matrices , buffer , start , end .add (offset ), color );
192+ drawLine (matrices , buffer , start , end .add (offset ), color ,
193+ DEFAULT_LINE_WIDTH );
188194
189195 vcp .endBatch (layer );
190196 }
@@ -209,7 +215,8 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
209215 {
210216 if (enforceVisibility && !NiceWurstModule .shouldRenderTarget (end ))
211217 continue ;
212- drawLine (matrices , buffer , start , end .add (offset ), color );
218+ drawLine (matrices , buffer , start , end .add (offset ), color ,
219+ DEFAULT_LINE_WIDTH );
213220 rendered = true ;
214221 }
215222
@@ -237,7 +244,8 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
237244 Vec3 point = end .point ();
238245 if (enforceVisibility && !NiceWurstModule .shouldRenderTarget (point ))
239246 continue ;
240- drawLine (matrices , buffer , start , point .add (offset ), end .color ());
247+ drawLine (matrices , buffer , start , point .add (offset ), end .color (),
248+ DEFAULT_LINE_WIDTH );
241249 rendered = true ;
242250 }
243251
@@ -263,12 +271,15 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
263271 Vec3 start = getTracerOrigin (partialTicks );
264272 Vec3 offset = getCameraPos ().reverse ();
265273 boolean rendered = false ;
274+ float appliedWidth =
275+ (float )Mth .clamp (lineWidth , MIN_LINE_WIDTH , MAX_LINE_WIDTH );
266276 for (ColoredPoint end : ends )
267277 {
268278 Vec3 point = end .point ();
269279 if (enforceVisibility && !NiceWurstModule .shouldRenderTarget (point ))
270280 continue ;
271- drawLine (matrices , buffer , start , point .add (offset ), end .color ());
281+ drawLine (matrices , buffer , start , point .add (offset ), end .color (),
282+ appliedWidth );
272283 rendered = true ;
273284 }
274285
@@ -278,6 +289,12 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
278289
279290 public static void drawLine (PoseStack matrices , VertexConsumer buffer ,
280291 Vec3 start , Vec3 end , int color )
292+ {
293+ drawLine (matrices , buffer , start , end , color , DEFAULT_LINE_WIDTH );
294+ }
295+
296+ private static void drawLine (PoseStack matrices , VertexConsumer buffer ,
297+ Vec3 start , Vec3 end , int color , float lineWidth )
281298 {
282299 Pose entry = matrices .last ();
283300 float x1 = (float )start .x ;
@@ -286,15 +303,23 @@ public static void drawLine(PoseStack matrices, VertexConsumer buffer,
286303 float x2 = (float )end .x ;
287304 float y2 = (float )end .y ;
288305 float z2 = (float )end .z ;
289- drawLine (entry , buffer , x1 , y1 , z1 , x2 , y2 , z2 , color );
306+ drawLine (entry , buffer , x1 , y1 , z1 , x2 , y2 , z2 , color , lineWidth );
290307 }
291308
292309 public static void drawLine (PoseStack .Pose entry , VertexConsumer buffer ,
293310 float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , int color )
311+ {
312+ drawLine (entry , buffer , x1 , y1 , z1 , x2 , y2 , z2 , color ,
313+ DEFAULT_LINE_WIDTH );
314+ }
315+
316+ private static void drawLine (PoseStack .Pose entry , VertexConsumer buffer ,
317+ float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , int color ,
318+ float lineWidth )
294319 {
295320 Vector3f normal = new Vector3f (x2 , y2 , z2 ).sub (x1 , y1 , z1 ).normalize ();
296- buffer .addVertex (entry , x1 , y1 , z1 ).setColor (color ). setNormal ( entry ,
297- normal );
321+ buffer .addVertex (entry , x1 , y1 , z1 ).setColor (color )
322+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
298323
299324 // If the line goes through the screen, add another vertex there. This
300325 // works around a bug in Minecraft's line shader.
@@ -303,22 +328,24 @@ public static void drawLine(PoseStack.Pose entry, VertexConsumer buffer,
303328 if (t > 0 && t < length )
304329 {
305330 Vector3f closeToCam = new Vector3f (normal ).mul (t ).add (x1 , y1 , z1 );
306- buffer .addVertex (entry , closeToCam ).setColor (color ). setNormal ( entry ,
307- normal );
308- buffer .addVertex (entry , closeToCam ).setColor (color ). setNormal ( entry ,
309- normal );
331+ buffer .addVertex (entry , closeToCam ).setColor (color )
332+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
333+ buffer .addVertex (entry , closeToCam ).setColor (color )
334+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
310335 }
311336
312- buffer .addVertex (entry , x2 , y2 , z2 ).setColor (color ). setNormal ( entry ,
313- normal );
337+ buffer .addVertex (entry , x2 , y2 , z2 ).setColor (color )
338+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
314339 }
315340
316341 public static void drawLine (VertexConsumer buffer , float x1 , float y1 ,
317342 float z1 , float x2 , float y2 , float z2 , int color )
318343 {
319344 Vector3f n = new Vector3f (x2 , y2 , z2 ).sub (x1 , y1 , z1 ).normalize ();
320- buffer .addVertex (x1 , y1 , z1 ).setColor (color ).setNormal (n .x , n .y , n .z );
321- buffer .addVertex (x2 , y2 , z2 ).setColor (color ).setNormal (n .x , n .y , n .z );
345+ buffer .addVertex (x1 , y1 , z1 ).setColor (color ).setNormal (n .x , n .y , n .z )
346+ .setLineWidth (DEFAULT_LINE_WIDTH );
347+ buffer .addVertex (x2 , y2 , z2 ).setColor (color ).setNormal (n .x , n .y , n .z )
348+ .setLineWidth (DEFAULT_LINE_WIDTH );
322349 }
323350
324351 public static void drawCurvedLine (PoseStack matrices , List <Vec3 > points ,
0 commit comments