44import dsns .betterhud .util .CustomText ;
55import dsns .betterhud .util .ModSettings ;
66import dsns .betterhud .util .Setting ;
7- import java .util .HashMap ;
7+ import java .util .ArrayList ;
8+ import java .util .LinkedHashMap ;
9+ import java .util .List ;
10+ import java .util .Map ;
811import net .minecraft .client .MinecraftClient ;
912import net .minecraft .entity .player .PlayerEntity ;
1013
1114class CoordinatesSettings extends ModSettings {
1215
1316 public CoordinatesSettings (String position ) {
1417 super (position );
15- HashMap <String , Setting > settings = super .getSettings ();
16- settings .put ("decimal" , Setting .createBooleanSetting (false ));
18+ LinkedHashMap <String , Setting > settings = super .getSettings ();
19+
20+ List <Map .Entry <String , Setting >> entries = new ArrayList <>(
21+ settings .entrySet ()
22+ );
23+ settings .clear ();
24+
25+ int insertIndex = 2 ;
26+
27+ for (int i = 0 ; i < Math .min (insertIndex , entries .size ()); i ++) {
28+ Map .Entry <String , Setting > entry = entries .get (i );
29+ settings .put (entry .getKey (), entry .getValue ());
30+ }
31+
32+ settings .put ("Decimal" , Setting .createBooleanSetting (false ));
33+
34+ for (int i = insertIndex ; i < entries .size (); i ++) {
35+ Map .Entry <String , Setting > entry = entries .get (i );
36+ settings .put (entry .getKey (), entry .getValue ());
37+ }
1738 }
1839}
1940
@@ -39,28 +60,21 @@ public CustomText onStartTick(MinecraftClient client) {
3960
4061 if (player == null ) return null ;
4162
42-
43-
44- if (SETTINGS .getSetting ("decimal" ).getBooleanValue ()) {
63+ if (SETTINGS .getSetting ("Decimal" ).getBooleanValue ()) {
4564 String roundX = String .format ("%.2f" , player .getX ());
4665 String roundY = String .format ("%.2f" , player .getY ());
4766 String roundZ = String .format ("%.2f" , player .getZ ());
48-
67+
4968 return new CustomText (
5069 roundX + ", " + roundY + ", " + roundZ ,
5170 getModSettings ()
5271 );
5372 } else {
54- String roundX = String .format ("%d" , player .getX ());
55- String roundY = String .format ("%d" , player .getY ());
56- String roundZ = String .format ("%d" , player .getZ ());
57-
58- return new CustomText (
59- roundX + ", " + roundY + ", " + roundZ ,
60- getModSettings ()
61- );
62- }
73+ int x = (int ) player .getX ();
74+ int y = (int ) player .getY ();
75+ int z = (int ) player .getZ ();
6376
64-
77+ return new CustomText (x + ", " + y + ", " + z , getModSettings ());
78+ }
6579 }
6680}
0 commit comments