Skip to content

Commit 2724a67

Browse files
committed
Improve compass movement.
1 parent 6fff0e1 commit 2724a67

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val platform = "4.3.4"
3131
val targetJavaVersion = 21
3232
val velocity = "3.4.0"
3333
val bStats = "3.1.0"
34-
val betterCommand = "168d199954"
34+
val betterCommand = "1.1"
3535

3636
val supportedMinecraftVersions = listOf(
3737
//1.17

dist/src/main/kotlin/kr/toxicity/hud/compass/CircleCompass.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@ class CircleCompass(
222222
val yaw = player.location().yaw.toDouble()
223223
var degree = yaw
224224
if (degree < 0) degree += 360.0
225-
val div = (degree / 90 * length).roundToInt()
225+
val quarterDegree = degree / 90 * length
226+
val div = quarterDegree.toInt()
226227
var comp = EMPTY_WIDTH_COMPONENT
227228
val lengthDiv = length / 2
228-
val mod = (degree.toInt() % length).toDouble() / length
229+
val mod = quarterDegree - div - 0.5
229230
val loc = player.location()
230231
val world = player.world()
231232
for (i in 1..<length) {
@@ -240,8 +241,8 @@ class CircleCompass(
240241
0, length * 4 -> images.s
241242
else -> images.chain
242243
}?.map?.get(CompassData(if (i > lengthDiv) length - i else i))?.let {
243-
val glyphWidth = ((it.width + space) * (mod - 0.5)).roundToInt()
244-
(glyphWidth + space).toSpaceComponent() + it + (-glyphWidth + space).toSpaceComponent()
244+
val move = (mod * (space * 2 + it.width)).roundToInt()
245+
(space + move).toSpaceComponent() + it + (space - move).toSpaceComponent()
245246
} ?: (space * 2).toSpaceComponent()
246247
}
247248
player.pointedLocation.forEach {

0 commit comments

Comments
 (0)