diff options
author | Linnea Gräf <nea@nea.moe> | 2024-08-07 21:34:16 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-08-07 21:34:16 +0200 |
commit | b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9 (patch) | |
tree | 1f7928e5587b6d4d7ca071949f0a70bf81282c14 /src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt | |
parent | 9b277bd897490d13ee4549a086e8d1b5f4cd0e10 (diff) | |
download | firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.tar.gz firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.tar.bz2 firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.zip |
Add /firm npcs command
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt b/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt index 7a20346..ca8bac6 100644 --- a/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt +++ b/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt @@ -31,8 +31,8 @@ object WarpUtil { private var lastAttemptedWarp = "" private var lastWarpAttempt = TimeMark.farPast() fun findNearestWarp(island: SkyBlockIsland, pos: Position): Islands.Warp? { - return warps.minByOrNull { - if (island.locrawMode != it.mode || (DConfig.data?.excludedWarps?.contains(it.warp) == true)) { + return warps.asSequence().filter { it.mode == island.locrawMode }.minByOrNull { + if (DConfig.data?.excludedWarps?.contains(it.warp) == true) { return@minByOrNull Double.MAX_VALUE } else { return@minByOrNull squaredDist(pos, it) @@ -48,8 +48,11 @@ object WarpUtil { } fun teleportToNearestWarp(island: SkyBlockIsland, pos: Position) { - val nearestWarp = findNearestWarp(island, pos) ?: return - + val nearestWarp = findNearestWarp(island, pos) + if (nearestWarp == null) { + MC.sendChat(Text.literal("Could not find an unlocked warp in ${island.userFriendlyName}")) + return + } if (island == SBData.skyblockLocation && sqrt(squaredDist(pos, nearestWarp)) > 1.1 * sqrt(squaredDist((MC.player ?: return).pos, nearestWarp)) ) { |