diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
-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) |