@@ -42,6 +42,10 @@ public enum RenderUtils
4242{
4343 ;
4444
45+ private static final float DEFAULT_LINE_WIDTH = 2F ;
46+ private static final double MIN_LINE_WIDTH = 0.5 ;
47+ private static final double MAX_LINE_WIDTH = 20 ;
48+
4549 public static void applyRegionalRenderOffset (PoseStack matrixStack )
4650 {
4751 applyRegionalRenderOffset (matrixStack , getCameraRegion ());
@@ -128,7 +132,8 @@ public static void drawLine(PoseStack matrices, Vec3 start, Vec3 end,
128132 VertexConsumer buffer = vcp .getBuffer (layer );
129133
130134 Vec3 offset = getCameraPos ().reverse ();
131- drawLine (matrices , buffer , start .add (offset ), end .add (offset ), color );
135+ drawLine (matrices , buffer , start .add (offset ), end .add (offset ), color ,
136+ DEFAULT_LINE_WIDTH );
132137
133138 vcp .endBatch (layer );
134139 }
@@ -159,7 +164,8 @@ public static void drawTracer(PoseStack matrices, float partialTicks,
159164
160165 Vec3 start = getTracerOrigin (partialTicks );
161166 Vec3 offset = getCameraPos ().reverse ();
162- drawLine (matrices , buffer , start , end .add (offset ), color );
167+ drawLine (matrices , buffer , start , end .add (offset ), color ,
168+ DEFAULT_LINE_WIDTH );
163169
164170 vcp .endBatch (layer );
165171 }
@@ -184,7 +190,8 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
184190 {
185191 if (enforceVisibility && !NiceWurstModule .shouldRenderTarget (end ))
186192 continue ;
187- drawLine (matrices , buffer , start , end .add (offset ), color );
193+ drawLine (matrices , buffer , start , end .add (offset ), color ,
194+ DEFAULT_LINE_WIDTH );
188195 rendered = true ;
189196 }
190197
@@ -212,7 +219,8 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
212219 Vec3 point = end .point ();
213220 if (enforceVisibility && !NiceWurstModule .shouldRenderTarget (point ))
214221 continue ;
215- drawLine (matrices , buffer , start , point .add (offset ), end .color ());
222+ drawLine (matrices , buffer , start , point .add (offset ), end .color (),
223+ DEFAULT_LINE_WIDTH );
216224 rendered = true ;
217225 }
218226
@@ -238,12 +246,15 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
238246 Vec3 start = getTracerOrigin (partialTicks );
239247 Vec3 offset = getCameraPos ().reverse ();
240248 boolean rendered = false ;
249+ float appliedWidth =
250+ (float )Mth .clamp (lineWidth , MIN_LINE_WIDTH , MAX_LINE_WIDTH );
241251 for (ColoredPoint end : ends )
242252 {
243253 Vec3 point = end .point ();
244254 if (enforceVisibility && !NiceWurstModule .shouldRenderTarget (point ))
245255 continue ;
246- drawLine (matrices , buffer , start , point .add (offset ), end .color ());
256+ drawLine (matrices , buffer , start , point .add (offset ), end .color (),
257+ appliedWidth );
247258 rendered = true ;
248259 }
249260
@@ -253,6 +264,12 @@ public static void drawTracers(PoseStack matrices, float partialTicks,
253264
254265 public static void drawLine (PoseStack matrices , VertexConsumer buffer ,
255266 Vec3 start , Vec3 end , int color )
267+ {
268+ drawLine (matrices , buffer , start , end , color , DEFAULT_LINE_WIDTH );
269+ }
270+
271+ private static void drawLine (PoseStack matrices , VertexConsumer buffer ,
272+ Vec3 start , Vec3 end , int color , float lineWidth )
256273 {
257274 Pose entry = matrices .last ();
258275 float x1 = (float )start .x ;
@@ -261,15 +278,23 @@ public static void drawLine(PoseStack matrices, VertexConsumer buffer,
261278 float x2 = (float )end .x ;
262279 float y2 = (float )end .y ;
263280 float z2 = (float )end .z ;
264- drawLine (entry , buffer , x1 , y1 , z1 , x2 , y2 , z2 , color );
281+ drawLine (entry , buffer , x1 , y1 , z1 , x2 , y2 , z2 , color , lineWidth );
265282 }
266283
267284 public static void drawLine (PoseStack .Pose entry , VertexConsumer buffer ,
268285 float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , int color )
286+ {
287+ drawLine (entry , buffer , x1 , y1 , z1 , x2 , y2 , z2 , color ,
288+ DEFAULT_LINE_WIDTH );
289+ }
290+
291+ private static void drawLine (PoseStack .Pose entry , VertexConsumer buffer ,
292+ float x1 , float y1 , float z1 , float x2 , float y2 , float z2 , int color ,
293+ float lineWidth )
269294 {
270295 Vector3f normal = new Vector3f (x2 , y2 , z2 ).sub (x1 , y1 , z1 ).normalize ();
271- buffer .addVertex (entry , x1 , y1 , z1 ).setColor (color ). setNormal ( entry ,
272- normal . x , normal . y , normal . z );
296+ buffer .addVertex (entry , x1 , y1 , z1 ).setColor (color )
297+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
273298
274299 // If the line goes through the screen, add another vertex there. This
275300 // works around a bug in Minecraft's line shader.
@@ -278,22 +303,24 @@ public static void drawLine(PoseStack.Pose entry, VertexConsumer buffer,
278303 if (t > 0 && t < length )
279304 {
280305 Vector3f closeToCam = new Vector3f (normal ).mul (t ).add (x1 , y1 , z1 );
281- buffer .addVertex (entry , closeToCam ).setColor (color ). setNormal ( entry ,
282- normal . x , normal . y , normal . z );
283- buffer .addVertex (entry , closeToCam ).setColor (color ). setNormal ( entry ,
284- normal . x , normal . y , normal . z );
306+ buffer .addVertex (entry , closeToCam ).setColor (color )
307+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
308+ buffer .addVertex (entry , closeToCam ).setColor (color )
309+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
285310 }
286311
287- buffer .addVertex (entry , x2 , y2 , z2 ).setColor (color ). setNormal ( entry ,
288- normal . x , normal . y , normal . z );
312+ buffer .addVertex (entry , x2 , y2 , z2 ).setColor (color )
313+ . setNormal ( entry , normal ). setLineWidth ( lineWidth );
289314 }
290315
291316 public static void drawLine (VertexConsumer buffer , float x1 , float y1 ,
292317 float z1 , float x2 , float y2 , float z2 , int color )
293318 {
294319 Vector3f n = new Vector3f (x2 , y2 , z2 ).sub (x1 , y1 , z1 ).normalize ();
295- buffer .addVertex (x1 , y1 , z1 ).setColor (color ).setNormal (n .x , n .y , n .z );
296- buffer .addVertex (x2 , y2 , z2 ).setColor (color ).setNormal (n .x , n .y , n .z );
320+ buffer .addVertex (x1 , y1 , z1 ).setColor (color ).setNormal (n .x , n .y , n .z )
321+ .setLineWidth (DEFAULT_LINE_WIDTH );
322+ buffer .addVertex (x2 , y2 , z2 ).setColor (color ).setNormal (n .x , n .y , n .z )
323+ .setLineWidth (DEFAULT_LINE_WIDTH );
297324 }
298325
299326 public static void drawCurvedLine (PoseStack matrices , List <Vec3 > points ,
0 commit comments