diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-27 22:48:46 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-27 22:48:46 +0100 |
commit | 0bc653bf143ba9e0f8e645d8a23a4801d814fc55 (patch) | |
tree | 5a8544425c1903f1d8014e23ee1e155b0edd75d9 /src/main/java/at/hannibal2/skyhanni | |
parent | 639c14d765e33a5afc73a500e21490886632137c (diff) | |
download | skyhanni-0bc653bf143ba9e0f8e645d8a23a4801d814fc55.tar.gz skyhanni-0bc653bf143ba9e0f8e645d8a23a4801d814fc55.tar.bz2 skyhanni-0bc653bf143ba9e0f8e645d8a23a4801d814fc55.zip |
Mark the plots with pests on them in the world.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
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 |