Skip to content

Commit

Permalink
fix: NPE when opening Waypoint GUI
Browse files Browse the repository at this point in the history
also use Origin as default instead of saying all are equal
  • Loading branch information
My-Name-Is-Jeff committed Dec 17, 2023
1 parent b5d21b2 commit 73fe284
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/kotlin/gg/skytils/skytilsmod/gui/WaypointsGui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import gg.essential.vigilance.gui.settings.ColorComponent
import gg.essential.vigilance.gui.settings.DropDown
import gg.essential.vigilance.utils.onLeftClick
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.core.PersistentSave
import gg.skytils.skytilsmod.core.tickTimer
import gg.skytils.skytilsmod.features.impl.handlers.Waypoint
Expand All @@ -56,7 +55,7 @@ class WaypointsGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2), Reopenab
private val categoryContainers = HashMap<UIContainer, Category>()

init {
lastUpdatedPlayerPosition = mc.thePlayer?.position
lastUpdatedPlayerPosition = Skytils.mc.thePlayer?.position ?: BlockPos.ORIGIN

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

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

Expand Down

0 comments on commit 73fe284

Please sign in to comment.