@@ -15,7 +15,10 @@ internal object Coordinates : LabelHud(
15
15
private val showX by setting(" Show X" , true )
16
16
private val showY by setting(" Show Y" , true )
17
17
private val showZ by setting(" Show Z" , true )
18
+ private val showXYZText by setting(" Show XYZ Text" , true )
18
19
private val showNetherOverworld by setting(" Show Nether/Overworld" , true )
20
+ private val printDimensionName by setting(" Print Dimension Name" , false )
21
+ private val showNetherOverworldMultiline by setting(" Show Nether/Overworld Multiline" , false , { showNetherOverworld })
19
22
private val decimalPlaces by setting(" Decimal Places" , 1 , 0 .. 4 , 1 )
20
23
private val thousandsSeparator by setting(" Thousands Separator" , false )
21
24
@@ -24,42 +27,48 @@ internal object Coordinates : LabelHud(
24
27
25
28
override fun SafeClientEvent.updateText () {
26
29
val entity = mc.renderViewEntity ? : player
27
-
28
- displayText.add(" XYZ" , secondaryColor)
29
- displayText.addLine(getFormattedCoords(entity.positionVector))
30
-
30
+ if (showXYZText) {
31
+ displayText.add(" XYZ" , secondaryColor)
32
+ }
33
+ if (showNetherOverworldMultiline)
34
+ displayText.addLine(getFormattedCoords(entity.positionVector))
35
+ else
36
+ displayText.add(getFormattedCoords(entity.positionVector))
31
37
if (showNetherOverworld) {
32
- when (entity .dimension) {
38
+ when (world.provider .dimension) {
33
39
- 1 -> { // Nether
34
- displayText.add(" Overworld " , secondaryColor)
35
- displayText.addLine (getFormattedCoords(entity.positionVector * netherToOverworld))
40
+ if (printDimensionName) displayText.add(" Nether " , secondaryColor)
41
+ displayText.add (getFormattedCoords(entity.positionVector * netherToOverworld, true ))
36
42
}
37
43
0 -> { // Overworld
38
- displayText.add(" Nether" , secondaryColor)
39
- displayText.addLine(getFormattedCoords(entity.positionVector * overworldToNether))
44
+ if (printDimensionName)
45
+ displayText.add(" Overworld" , secondaryColor)
46
+ displayText.add(getFormattedCoords(entity.positionVector * overworldToNether, true ))
40
47
}
41
48
}
42
49
}
43
50
}
44
51
45
- private fun getFormattedCoords (pos : Vec3d ): TextComponent .TextElement {
52
+ private fun getFormattedCoords (pos : Vec3d , brackets : Boolean = false): TextComponent .TextElement {
53
+ if (! showX && ! showY && ! showZ) return TextComponent .TextElement (" " , primaryColor)
46
54
val x = roundOrInt(pos.x)
47
55
val y = roundOrInt(pos.y)
48
56
val z = roundOrInt(pos.z)
49
57
return StringBuilder ().run {
58
+ if (brackets) append(" [" )
50
59
if (showX) append(x)
51
60
if (showY) appendWithComma(y)
52
61
if (showZ) appendWithComma(z)
62
+ if (brackets) append(" ]" )
53
63
TextComponent .TextElement (toString(), primaryColor)
54
64
}
55
65
}
56
66
57
67
private fun roundOrInt (input : Double ): String {
58
68
val separatorFormat = if (thousandsSeparator) " ," else " "
59
-
60
69
return " %$separatorFormat .${decimalPlaces} f" .format(input)
61
70
}
62
71
63
- private fun StringBuilder.appendWithComma (string : String ) = append(if (length > 0 ) " , $string " else string)
72
+ private fun StringBuilder.appendWithComma (string : String ) = append(if (isNotEmpty() ) " , $string " else string)
64
73
65
74
}
0 commit comments