aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-17 14:08:46 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-17 14:08:46 +0100
commitbeb28a72410852cda6d2ad88287307e3ef8d6325 (patch)
tree22476e06335f5932f3a5ad5337e6cc75fecad14a /src/main/java/at/hannibal2/skyhanni/features
parent281d49fe7853b3819a485e55b73318594e166e53 (diff)
downloadskyhanni-beb28a72410852cda6d2ad88287307e3ef8d6325.tar.gz
skyhanni-beb28a72410852cda6d2ad88287307e3ef8d6325.tar.bz2
skyhanni-beb28a72410852cda6d2ad88287307e3ef8d6325.zip
Show the closest plot border when outside a garden plot.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
index 893e31cbf..e9e651626 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.renderPlot
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -34,10 +35,12 @@ object GardenPlotBorders {
fun render(event: LorenzRenderWorldEvent) {
if (!isEnabled()) return
if (!showBorders) return
- val plot = GardenPlotAPI.getCurrentPlot() ?: return
+ val plot = GardenPlotAPI.getCurrentPlot() ?: getClosestPlot() ?: return
event.renderPlot(plot, LorenzColor.YELLOW.toColor(), LorenzColor.DARK_BLUE.toColor())
}
+ private fun getClosestPlot(): GardenPlotAPI.Plot? =
+ GardenPlotAPI.plots.minByOrNull { it.middle.distanceSqToPlayer() }
fun isEnabled() = GardenAPI.inGarden() && config
}