Skip to content

Commit

Permalink
fix: WaypointGui saves player coords to prevent comparator error
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Dec 9, 2023
1 parent 1219dcb commit f2039e2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/kotlin/gg/skytils/skytilsmod/gui/WaypointsGui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class WaypointsGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2), Reopenab
private val categoryContainers = HashMap<UIContainer, Category>()

init {
lastUpdatedPlayerPosition = mc.thePlayer?.position

scrollComponent = ScrollComponent(
innerPadding = 4f,
).childOf(window).constrain {
Expand Down Expand Up @@ -692,13 +694,13 @@ class WaypointsGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2), Reopenab
a.name.compareTo(b.name)
}),
CLOSEST("Closest", { a, b ->
val distanceA = mc.thePlayer?.getDistanceSq(a.pos) ?: 0.0
val distanceB = mc.thePlayer?.getDistanceSq(b.pos) ?: 0.0
val distanceA = lastUpdatedPlayerPosition?.distanceSq(a.pos) ?: 0.0
val distanceB = lastUpdatedPlayerPosition?.distanceSq(b.pos) ?: 0.0
distanceA.compareTo(distanceB)
}),
FARTHEST("Farthest", { a, b ->
val distanceA = mc.thePlayer?.getDistanceSq(a.pos) ?: 0.0
val distanceB = mc.thePlayer?.getDistanceSq(b.pos) ?: 0.0
val distanceA = lastUpdatedPlayerPosition?.distanceSq(a.pos) ?: 0.0
val distanceB = lastUpdatedPlayerPosition?.distanceSq(b.pos) ?: 0.0
distanceB.compareTo(distanceA)
}),
RECENT("Recent", { a, b ->
Expand All @@ -715,6 +717,7 @@ class WaypointsGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2), Reopenab

companion object {
const val CATEGORY_INNER_PADDING = 7.5
var lastUpdatedPlayerPosition: BlockPos? = null
}
}

Expand Down

0 comments on commit f2039e2

Please sign in to comment.