aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt13
4 files changed, 27 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 94e763f3b..b7ad90f40 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -635,7 +635,7 @@ class SkyHanniMod {
loadModule(AccountUpgradeReminder())
loadModule(PetExpTooltip())
loadModule(Translator())
- loadModule(GardenPlotBorders())
+ loadModule(GardenPlotBorders)
loadModule(CosmeticFollowingLine())
loadModule(SuperpairsClicksAlert())
loadModule(PowderTracker)
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 e92df8750..9f4b69d12 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
@@ -21,12 +21,12 @@ public class PestFinderConfig {
@Expose
@ConfigOption(
- name = "Waypoint In World",
- desc = "Mark the plots with pests on them in the world."
+ name = "Show Plot in World",
+ desc = "Mark infected plot names and world border in the world."
)
@ConfigEditorBoolean
@FeatureToggle
- public boolean waypointInWorld = true;
+ public boolean showPlotInWorld = true;
@Expose
@ConfigOption(
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 7c3fc26a5..409caaa85 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
@@ -6,19 +6,17 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.SimpleTimeMark
-import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.input.Keyboard
import java.awt.Color
import kotlin.math.floor
import kotlin.time.Duration.Companion.milliseconds
-class GardenPlotBorders {
+object GardenPlotBorders {
private val config get() = GardenAPI.config.plotBorders
private var timeLastSaved = SimpleTimeMark.farPast()
private var showBorders = false
- private val LINE_COLOR = LorenzColor.YELLOW.toColor()
private fun LorenzVec.addX(x: Int) = add(x, 0, 0)
private fun LorenzVec.addZ(z: Int) = add(0, 0, z)
@@ -43,26 +41,30 @@ class GardenPlotBorders {
fun render(event: LorenzRenderWorldEvent) {
if (!isEnabled()) return
if (!showBorders) return
+ val plot = GardenPlotAPI.getCurrentPlot() ?: return
+ event.render(plot, LorenzColor.YELLOW.toColor(), LorenzColor.DARK_BLUE.toColor())
+ }
- val entity = Minecraft.getMinecraft().renderViewEntity
-
- // Lowest point in the garden
- val minHeight = 66
- val maxHeight = 256
+ fun LorenzRenderWorldEvent.render(plot: GardenPlotAPI.Plot, LINE_COLOR: Color, cornerColor: Color) {
+ val event = this
// These don't refer to Minecraft chunks but rather garden plots, but I use
// the word chunk as the logic closely represents how chunk borders are rendered in latter mc versions
- val chunkX = floor((entity.posX + 48) / 96).toInt()
- val chunkZ = floor((entity.posZ + 48) / 96).toInt()
+ val chunkX = floor((plot.middle.x + 48) / 96).toInt()
+ val chunkZ = floor((plot.middle.z + 48) / 96).toInt()
val chunkMinX = (chunkX * 96) - 48
val chunkMinZ = (chunkZ * 96) - 48
+ // Lowest point in the garden
+ val minHeight = 66
+ val maxHeight = 256
+
// Render 4 vertical corners
for (i in 0..96 step 96) {
for (j in 0..96 step 96) {
val start = LorenzVec(chunkMinX + i, minHeight, chunkMinZ + j)
val end = LorenzVec(chunkMinX + i, maxHeight, chunkMinZ + j)
- event.tryDraw3DLine(start, end, LorenzColor.DARK_BLUE.toColor(), 2, true)
+ event.tryDraw3DLine(start, end, cornerColor, 2, true)
}
}
@@ -112,7 +114,6 @@ class GardenPlotBorders {
draw3DLine(p1, p2, color, lineWidth, depth)
}
-
private fun isOutOfBorders(location: LorenzVec) = when {
location.x > 240 -> true
location.x < -240 -> true
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 00fd0775e..19b794757 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
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isPlayerInside
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.features.garden.GardenPlotBorders.render
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
@@ -175,18 +176,24 @@ class PestFinder {
@SubscribeEvent
fun onRenderWorld(event: LorenzRenderWorldEvent) {
if (!isEnabled()) return
- if (!config.waypointInWorld) return
+ if (!config.showPlotInWorld) return
if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand()) return
val playerLocation = event.exactPlayerEyeLocation()
for (plot in getPlotsWithPests()) {
- if (plot.isPlayerInside()) continue
+ if (plot.isPlayerInside()) {
+ event.render(plot, LorenzColor.RED.toColor(), LorenzColor.DARK_RED.toColor())
+ continue
+ }
+ event.render(plot, LorenzColor.GOLD.toColor(), LorenzColor.RED.toColor())
+
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)
event.drawWaypointFilled(location, LorenzColor.RED.toColor())
event.drawDynamicText(location, "§c$pestsName §7in §b$plotName", 1.5)
+
}
}
@@ -215,5 +222,5 @@ class PestFinder {
plot.sendTeleportTo()
}
- fun isEnabled() = GardenAPI.inGarden() && (config.showDisplay || config.waypointInWorld)
+ fun isEnabled() = GardenAPI.inGarden() && (config.showDisplay || config.showPlotInWorld)
}