aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt10
4 files changed, 56 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java
index 444da848d..e527a5933 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java
@@ -19,8 +19,17 @@ public class PestFinderConfig {
@Expose
@ConfigOption(
+ name = "Waypoint In World",
+ desc = "Mark the plots with pests on them in the world."
+ )
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean waypointInWorld = true;
+
+ @Expose
+ @ConfigOption(
name = "Only With Vacuum",
- desc = "Only show the pest display while holding a vacuum in the hand."
+ desc = "Only show the pest display and waypoints while holding a vacuum in the hand."
)
@ConfigEditorBoolean
public boolean onlyWithVacuum = true;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
index 0d6905edf..e66a468ae 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.isInside
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import com.google.gson.annotations.Expose
import net.minecraft.util.AxisAlignedBB
@@ -21,7 +22,7 @@ object GardenPlotAPI {
return plots.firstOrNull { it.box.isInside(location) }
}
- class Plot(val id: Int, var inventorySlot: Int, val box: AxisAlignedBB)
+ class Plot(val id: Int, var inventorySlot: Int, val box: AxisAlignedBB, val middle: LorenzVec)
class PlotData(
@Expose
@@ -70,10 +71,11 @@ object GardenPlotAPI {
val minY = ((y - 2) * 96 - 48).toDouble()
val maxX = ((x - 2) * 96 + 48).toDouble()
val maxY = ((y - 2) * 96 + 48).toDouble()
- val box = AxisAlignedBB(minX, 0.0, minY, maxX, 256.0, maxY)
- list.add(
- Plot(id, slot, box)
- )
+ val a = LorenzVec(minX, 0.0, minY)
+ val b = LorenzVec(maxX, 256.0, maxY)
+ val middle = a.interpolate(b, 0.5).copy(y = 10.0)
+ val box = a.axisAlignedTo(b)
+ list.add(Plot(id, slot, box, middle))
slot++
}
slot += 4
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
index 1e879f938..21bf9bcdd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
@@ -5,15 +5,21 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.garden.pests.PestSpawnEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.sendTeleportTo
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils
@@ -79,13 +85,13 @@ class PestFinder {
val pests = plot.pests
if (pests == 0) continue
- val name = plot.name
+ val plotName = plot.name
val pestsName = StringUtils.optionalPlural(pests, "pest", "pests")
val renderable = Renderable.clickAndHover(
- "§c$pestsName §7in §b$name",
+ "§c$pestsName §7in §b$plotName",
listOf(
"§7Pests Found: §e$pests",
- "§7In plot §b$name",
+ "§7In plot §b$plotName",
"",
"§eClick here to warp!"
),
@@ -135,6 +141,7 @@ class PestFinder {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent) {
if (!isEnabled()) return
+ if (!config.showDisplay) return
if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand()) return
if (GardenAPI.inGarden() && config.showDisplay) {
@@ -142,5 +149,23 @@ class PestFinder {
}
}
- fun isEnabled() = GardenAPI.inGarden() && config.showDisplay
+ @SubscribeEvent
+ fun onRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!isEnabled()) return
+ if (!config.waypointInWorld) return
+ if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand()) return
+
+ val playerLocation = event.exactPlayerEyeLocation()
+ GardenPlotAPI.plots.filter { it.pests > 0 }.forEach { plot ->
+ val pestsName = StringUtils.optionalPlural(plot.pests, "pest", "pests")
+ val plotName = plot.name
+ val middle = plot.middle
+ val location = playerLocation.copy(x = middle.x, z = middle.z)
+ if (location.distanceToPlayer() < 15) return@forEach
+ event.drawWaypointFilled(location, LorenzColor.WHITE.toColor())
+ event.drawDynamicText(location, "§c$pestsName §7in §b$plotName", 1.5)
+ }
+ }
+
+ fun isEnabled() = GardenAPI.inGarden() && (config.showDisplay || config.waypointInWorld)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index fd38fd441..294053f83 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -132,6 +132,16 @@ data class LorenzVec(
fun axisAlignedTo(other: LorenzVec) = AxisAlignedBB(x, y, z, other.x, other.y, other.z)
+ fun interpolate(other: LorenzVec, factor: Double): LorenzVec {
+ require(factor in 0.0..1.0) { "Percentage must be between 0 and 1: $factor" }
+
+ val x = (1 - factor) * this.x + factor * other.x
+ val y = (1 - factor) * this.y + factor * other.y
+ val z = (1 - factor) * this.z + factor * other.z
+
+ return LorenzVec(x, y, z)
+ }
+
companion object {
fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec {
val yaw: Double = (yaw + 90) * Math.PI / 180