diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-04 03:54:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-04 03:54:10 +0200 |
commit | f4cc72e27f88fd7195436e17f1fb2dd394091755 (patch) | |
tree | 664e4a23a77a0ed0c213e46efc8dbac2e5bb2f71 /src/main/java/at/hannibal2/skyhanni | |
parent | e1dc6cd443912bc9dd1664c484f6c6b167641cfd (diff) | |
download | skyhanni-f4cc72e27f88fd7195436e17f1fb2dd394091755.tar.gz skyhanni-f4cc72e27f88fd7195436e17f1fb2dd394091755.tar.bz2 skyhanni-f4cc72e27f88fd7195436e17f1fb2dd394091755.zip |
Improvement: line to hoppity guess (#1669)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index 9ed976764..8b6ce2ad3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils @@ -18,10 +19,12 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraft.item.ItemStack import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds object HoppityEggLocator { @@ -30,6 +33,8 @@ object HoppityEggLocator { private val locatorItem = "EGGLOCATOR".asInternalName() private var lastParticlePosition: LorenzVec? = null + private var lastParticlePositionForever: LorenzVec? = null + private var lastChange = SimpleTimeMark.farPast() private val validParticleLocations = mutableListOf<LorenzVec>() private var drawLocations = false @@ -69,8 +74,22 @@ object HoppityEggLocator { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return - event.draw3DLine(firstPos, secondPos, LorenzColor.RED.toColor(), 2, false) - + val eyeLocation = event.exactPlayerEyeLocation() + lastParticlePositionForever?.let { + if (lastChange.passedSince() < 300.milliseconds) { + if (eyeLocation.distance(it) > 2) { + event.drawWaypointFilled( + it, + LorenzColor.GREEN.toColor(), + seeThroughBlocks = true, + ) + event.drawDynamicText(it.add(y = 1), "§aGuess", 1.5) + } + if (!drawLocations) { + event.draw3DLine(eyeLocation, it.add(0.5, 0.5, 0.5), LorenzColor.GREEN.toColor(), 2, false) + } + } + } if (drawLocations) { for ((index, eggLocation) in possibleEggLocations.withIndex()) { val eggLabel = "§aGuess #${index + 1}" @@ -80,6 +99,7 @@ object HoppityEggLocator { seeThroughBlocks = true, ) event.drawDynamicText(eggLocation.add(y = 1), eggLabel, 1.5) + event.draw3DLine(eyeLocation, eggLocation.add(0.5, 0.5, 0.5), LorenzColor.GREEN.toColor(), 2, false) } return } @@ -118,10 +138,13 @@ object HoppityEggLocator { fun onReceiveParticle(event: ReceiveParticleEvent) { if (!isEnabled()) return if (!hasLocatorInInventory()) return + if (GardenAPI.inGarden()) return if (!event.isVillagerParticle() && !event.isEnchantmentParticle()) return val lastParticlePosition = lastParticlePosition ?: run { lastParticlePosition = event.location + lastParticlePositionForever = lastParticlePosition + lastChange = SimpleTimeMark.now() return } if (lastParticlePosition == event.location) { |