aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-03-27 22:26:40 +0100
committerGitHub <noreply@github.com>2024-03-27 22:26:40 +0100
commit45b21ea54bc21d87ea0650afadcc474ddccf5249 (patch)
tree9aa8ca4644bbcda32d487f6711f6e626c94e793a /src/main/java/at/hannibal2
parentfcc1baa893d687f7572912f88736aa89cd5de445 (diff)
downloadskyhanni-45b21ea54bc21d87ea0650afadcc474ddccf5249.tar.gz
skyhanni-45b21ea54bc21d87ea0650afadcc474ddccf5249.tar.bz2
skyhanni-45b21ea54bc21d87ea0650afadcc474ddccf5249.zip
Fix: Pest Tracker Waypoint trigerring with some other particles (#1284)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt
index 96a14c059..ed444e52e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt
@@ -8,10 +8,10 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.ReceiveParticleEvent
+import at.hannibal2.skyhanni.events.garden.pests.PestUpdateEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
-import at.hannibal2.skyhanni.features.garden.GardenPlotAPI
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
-import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayerIgnoreY
import at.hannibal2.skyhanni.utils.LocationUtils.playerLocation
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -40,25 +40,26 @@ class PestParticleWaypoint {
private var locations = mutableListOf<LorenzVec>()
private var particles = 0
private var lastParticles = 0
+ private var isPointingToPest = false
@SubscribeEvent
fun onItemClick(event: ItemClickEvent) {
if (!isEnabled()) return
if (PestAPI.hasVacuumInHand()) {
if (event.clickType == ClickType.LEFT_CLICK && !Minecraft.getMinecraft().thePlayer.isSneaking) {
- lastPestTrackerUse = SimpleTimeMark.now()
reset()
+ lastPestTrackerUse = SimpleTimeMark.now()
}
}
}
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
- lastPestTrackerUse = SimpleTimeMark.farPast()
reset()
}
private fun reset() {
+ lastPestTrackerUse = SimpleTimeMark.farPast()
locations.clear()
guessPoint = null
lastParticlePoint = null
@@ -66,13 +67,25 @@ class PestParticleWaypoint {
secondParticlePoint = null
particles = 0
lastParticles = 0
+ isPointingToPest = false
}
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
fun onReceiveParticle(event: ReceiveParticleEvent) {
if (!isEnabled()) return
- if (event.type != EnumParticleTypes.REDSTONE) return
+ if (event.type != EnumParticleTypes.REDSTONE || event.speed != 1f) return
+
+ val darkYellow = LorenzVec(0.0, 0.8, 0.0)
+ val yellow = LorenzVec(0.8, 0.8, 0.0)
+ val redPest = LorenzVec(0.8, 0.4, 0.0)
+ val redPlot = LorenzVec(0.8, 0.0, 0.0)
+ isPointingToPest = when (event.offset.round(5)) {
+ redPlot -> false
+ redPest, yellow, darkYellow -> true
+ else -> return
+ }
val location = event.location
+
if (config.hideParticles) event.cancel()
if (lastPestTrackerUse.passedSince() > 3.seconds) return
@@ -112,11 +125,9 @@ class PestParticleWaypoint {
}
val waypoint = getWaypoint() ?: return
- val distance = GardenPlotAPI.closestCenterPlot(waypoint)?.distanceIgnoreY(waypoint) ?: return
- val isCloseToPlotCenter = distance < 4
- val text = if (isCloseToPlotCenter) "§cInfected Plot Guess" else "§aPest Guess"
- val color = if (isCloseToPlotCenter) LorenzColor.RED else LorenzColor.GREEN
+ val text = if (isPointingToPest) "§aPest Guess" else "§cInfected Plot Guess"
+ val color = if (isPointingToPest) LorenzColor.GREEN else LorenzColor.RED
event.drawWaypointFilled(waypoint, color.toColor(), beacon = true)
event.drawDynamicText(waypoint, text, 1.3)
@@ -139,14 +150,18 @@ class PestParticleWaypoint {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
- if (lastPestTrackerUse.passedSince() !in 1.seconds..config.showForSeconds.seconds) return
val guessPoint = guessPoint ?: return
- if (guessPoint.distanceToPlayer() > 8.0) return
- lastPestTrackerUse = SimpleTimeMark.farPast()
+ if (guessPoint.distanceToPlayerIgnoreY() > 8) return
+ if (isPointingToPest && lastPestTrackerUse.passedSince() !in 1.seconds..config.showForSeconds.seconds) return
reset()
}
+ @SubscribeEvent
+ fun onPestUpdate(event: PestUpdateEvent) {
+ if (PestAPI.scoreboardPests == 0) reset()
+ }
+
private fun calculateWaypoint(list: MutableList<LorenzVec>): LorenzVec? {
val firstParticle = firstParticlePoint ?: return null