summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorappable <enzospiacitelli@gmail.com>2024-05-28 23:47:36 -0700
committerGitHub <noreply@github.com>2024-05-29 08:47:36 +0200
commitf6a31d6a3f6caf1ad3476f9019b8bd278d7e1c3d (patch)
treefdbba96ae6f3a67caa45bf88cabf826f910d4f82 /src/main/java/at/hannibal2/skyhanni/features
parentc8043a2c0b4dbd0733a316f2ed9b4f8c8d605056 (diff)
downloadskyhanni-f6a31d6a3f6caf1ad3476f9019b8bd278d7e1c3d.tar.gz
skyhanni-f6a31d6a3f6caf1ad3476f9019b8bd278d7e1c3d.tar.bz2
skyhanni-f6a31d6a3f6caf1ad3476f9019b8bd278d7e1c3d.zip
Feature: Last farmed location waypoint (#1335)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt
index b746e03ea..9188b66eb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt
@@ -1,18 +1,23 @@
package at.hannibal2.skyhanni.features.garden.farming
+import at.hannibal2.skyhanni.config.features.garden.CropStartLocationConfig.CropLocationMode
+import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GardenStartLocation {
private val config get() = GardenAPI.config.cropStartLocation
+ private var shouldShowLastFarmedWaypoint = false
fun setLocationCommand() {
if (!GardenAPI.inGarden()) {
@@ -46,7 +51,9 @@ object GardenStartLocation {
@SubscribeEvent
fun onCropClick(event: CropClickEvent) {
if (!isEnabled()) return
+ if (event.clickType != ClickType.LEFT_CLICK || !GardenAPI.hasFarmingToolInHand()) return
val startLocations = GardenAPI.storage?.cropStartLocations ?: return
+ val lastFarmedLocations = GardenAPI.storage?.cropLastFarmedLocations ?: return
val crop = GardenAPI.getCurrentlyFarmedCrop() ?: return
if (crop != GardenCropSpeed.lastBrokenCrop) return
@@ -54,18 +61,48 @@ object GardenStartLocation {
startLocations[crop] = LocationUtils.playerLocation()
ChatUtils.chat("Auto updated your Crop Start Location for ${crop.cropName}")
}
+
+ lastFarmedLocations[crop] = LorenzVec.getBlockBelowPlayer().add(0.0, 1.0, 0.0)
+ shouldShowLastFarmedWaypoint = false
}
@SubscribeEvent
fun onRenderWorld(event: LorenzRenderWorldEvent) {
if (!isEnabled()) return
- val startLocations = GardenAPI.storage?.cropStartLocations ?: return
val crop = GardenAPI.cropInHand ?: return
- val location = startLocations[crop]?.add(-0.5, 0.5, -0.5) ?: return
- event.drawWaypointFilled(location, LorenzColor.WHITE.toColor())
- event.drawDynamicText(location, crop.cropName, 1.5)
+ if (showStartWaypoint()) {
+ GardenAPI.storage?.cropStartLocations?.get(crop)
+ ?.roundLocationToBlock()
+ ?.also {
+ event.drawWaypointFilled(it, LorenzColor.WHITE.toColor())
+ event.drawDynamicText(it, "§b${crop.cropName}", 1.5)
+ if (shouldShowBoth()) {
+ event.drawDynamicText(it, "§aStart Location", 1.1, yOff = 12f)
+ }
+ }
+ }
+
+ if (showLastFarmedWaypoint()) {
+ val location = GardenAPI.storage?.cropLastFarmedLocations?.get(crop)
+ if (location != null) {
+ if (location.distanceSqToPlayer() >= 100.0) {
+ shouldShowLastFarmedWaypoint = true
+ }
+ if (shouldShowLastFarmedWaypoint) {
+ event.drawWaypointFilled(location, LorenzColor.LIGHT_PURPLE.toColor(), seeThroughBlocks = true, beacon = true)
+ event.drawDynamicText(location, "§b${crop.cropName}", 1.5)
+ if (shouldShowBoth()) {
+ event.drawDynamicText(location, "§eLast Farmed", 1.1, yOff = 12f)
+ }
+ }
+ }
+ }
}
+ private fun shouldShowBoth() = config.mode == CropLocationMode.BOTH
+ private fun showStartWaypoint() = config.mode != CropLocationMode.LAST_FARMED
+ private fun showLastFarmedWaypoint() = config.mode != CropLocationMode.START
+
fun isEnabled() = GardenAPI.inGarden() && config.enabled
}