diff options
author | Linnea Gräf <nea@nea.moe> | 2024-01-19 00:25:02 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-01-19 00:25:02 +0100 |
commit | dcb769967dce8c4e98f035c23f5167553750a94a (patch) | |
tree | 5f584ada4028199c3054c508da9944a685533f04 /src/main/kotlin/moe/nea/firmament/features/diana | |
parent | 7255bb655768c0b9a9e6a04e4e69eb264047ef1b (diff) | |
download | firmament-dcb769967dce8c4e98f035c23f5167553750a94a.tar.gz firmament-dcb769967dce8c4e98f035c23f5167553750a94a.tar.bz2 firmament-dcb769967dce8c4e98f035c23f5167553750a94a.zip |
Add warp to diana guess keybind
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features/diana')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/diana/AncestralSpadeSolver.kt | 17 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/diana/DianaWaypoints.kt | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/diana/AncestralSpadeSolver.kt b/src/main/kotlin/moe/nea/firmament/features/diana/AncestralSpadeSolver.kt index 459fa3c..442d8cf 100644 --- a/src/main/kotlin/moe/nea/firmament/features/diana/AncestralSpadeSolver.kt +++ b/src/main/kotlin/moe/nea/firmament/features/diana/AncestralSpadeSolver.kt @@ -13,9 +13,11 @@ import net.minecraft.sound.SoundEvents import net.minecraft.util.math.Vec3d import moe.nea.firmament.events.ParticleSpawnEvent import moe.nea.firmament.events.SoundReceiveEvent +import moe.nea.firmament.events.WorldKeyboardEvent import moe.nea.firmament.events.WorldReadyEvent import moe.nea.firmament.events.WorldRenderLastEvent import moe.nea.firmament.util.TimeMark +import moe.nea.firmament.util.WarpUtil import moe.nea.firmament.util.render.RenderInWorldContext object AncestralSpadeSolver { @@ -26,6 +28,17 @@ object AncestralSpadeSolver { var nextGuess: Vec3d? = null private set + private var lastTeleportAttempt = TimeMark.farPast() + + fun onKeyBind(event: WorldKeyboardEvent) { + if (!DianaWaypoints.TConfig.ancestralSpadeSolver) return + if (!event.matches(DianaWaypoints.TConfig.ancestralSpadeTeleport)) return + + if (lastTeleportAttempt.passedTime() < 3.seconds) return + WarpUtil.teleportToNearestWarp("hub", nextGuess ?: return) + lastTeleportAttempt = TimeMark.now() + } + fun onParticleSpawn(event: ParticleSpawnEvent) { if (!DianaWaypoints.TConfig.ancestralSpadeSolver) return if (event.particleEffect != ParticleTypes.DRIPPING_LAVA) return @@ -57,7 +70,7 @@ object AncestralSpadeSolver { } val averagePitchDelta = - if (pitches.isEmpty()) 0.0 + if (pitches.isEmpty()) return else pitches .zipWithNext { a, b -> b - a } .average() @@ -86,7 +99,7 @@ object AncestralSpadeSolver { val cameraForward = Vector3f(0f, 0f, 1f).rotate(event.camera.rotation) line(event.camera.pos.add(Vec3d(cameraForward)), it, lineWidth = 3f) } - if (particlePositions.size > 2 && lastDing.passedTime() < 10.seconds) { + if (particlePositions.size > 2 && lastDing.passedTime() < 10.seconds && nextGuess != null) { color(0f, 1f, 0f, 0.7f) line(*particlePositions.toTypedArray()) } diff --git a/src/main/kotlin/moe/nea/firmament/features/diana/DianaWaypoints.kt b/src/main/kotlin/moe/nea/firmament/features/diana/DianaWaypoints.kt index 9f72967..9102497 100644 --- a/src/main/kotlin/moe/nea/firmament/features/diana/DianaWaypoints.kt +++ b/src/main/kotlin/moe/nea/firmament/features/diana/DianaWaypoints.kt @@ -11,6 +11,7 @@ import moe.nea.firmament.events.ParticleSpawnEvent import moe.nea.firmament.events.ProcessChatEvent import moe.nea.firmament.events.SoundReceiveEvent import moe.nea.firmament.events.UseBlockEvent +import moe.nea.firmament.events.WorldKeyboardEvent import moe.nea.firmament.events.WorldReadyEvent import moe.nea.firmament.events.WorldRenderLastEvent import moe.nea.firmament.features.FirmamentFeature @@ -22,6 +23,7 @@ object DianaWaypoints : FirmamentFeature { object TConfig : ManagedConfig(identifier) { val ancestralSpadeSolver by toggle("ancestral-spade") { true } + val ancestralSpadeTeleport by keyBindingWithDefaultUnbound("ancestral-teleport") val nearbyWaypoints by toggle("nearby-waypoints") { true } } @@ -38,6 +40,7 @@ object DianaWaypoints : FirmamentFeature { ProcessChatEvent.subscribe(NearbyBurrowsSolver::onChatEvent) + WorldKeyboardEvent.subscribe(AncestralSpadeSolver::onKeyBind) ParticleSpawnEvent.subscribe(AncestralSpadeSolver::onParticleSpawn) SoundReceiveEvent.subscribe(AncestralSpadeSolver::onPlaySound) WorldRenderLastEvent.subscribe(AncestralSpadeSolver::onWorldRender) |