@@ -24,7 +24,47 @@ default int drawString(FormattedCharSequence text, int x, int y)
2424		return  this .drawString (text , (float ) x , (float ) y );
2525	}
2626
27- 	int  drawString (String  text , float  x , float  y );
27+ 	default  int  drawCenteredString (String  text , int  x , int  y )
28+ 	{
29+ 		return  this .drawCenteredString (text , (float ) x , (float ) y );
30+ 	}
31+ 	
32+ 	default  int  drawCenteredString (Component  text , int  x , int  y )
33+ 	{
34+ 		return  this .drawCenteredString (text , (float ) x , (float ) y );
35+ 	}
36+ 	
37+ 	default  int  drawCenteredString (FormattedCharSequence  text , int  x , int  y )
38+ 	{
39+ 		return  this .drawCenteredString (text , (float ) x , (float ) y );
40+ 	}
41+ 	
42+ 	default  int  drawString (String  text , float  x , float  y )
43+ 	{
44+ 		return  this .drawString (Component .literal (text ), x , y );
45+ 	}
46+ 	
47+ 	default  int  drawString (Component  text , float  x , float  y )
48+ 	{
49+ 		return  this .drawString (text .getVisualOrderText (), x , y );
50+ 	}
2851
2952	int  drawString (FormattedCharSequence  text , float  x , float  y );
53+ 	
54+ 	default  int  drawCenteredString (String  text , float  x , float  y )
55+ 	{
56+ 		return  this .drawCenteredString (Component .literal (text ), x , y );
57+ 	}
58+ 	
59+ 	default  int  drawCenteredString (Component  text , float  x , float  y )
60+ 	{
61+ 		return  this .drawCenteredString (text .getVisualOrderText (), x , y );
62+ 	}
63+ 	
64+ 	default  int  drawCenteredString (FormattedCharSequence  text , float  x , float  y )
65+ 	{
66+ 		x  -= this .getFont ().width (text ) / 2f ;
67+ 		y  -= this .getFont ().lineHeight  / 2f ;
68+ 		return  this .drawString (text , (float ) Math .round (x ), (float ) Math .round (y ));
69+ 	}
3070}
0 commit comments