diff options
Diffstat (limited to 'src/main/kotlin/features/diana')
| -rw-r--r-- | src/main/kotlin/features/diana/AncestralSpadeSolver.kt | 35 | ||||
| -rw-r--r-- | src/main/kotlin/features/diana/DianaWaypoints.kt | 36 | ||||
| -rw-r--r-- | src/main/kotlin/features/diana/NearbyBurrowsSolver.kt | 19 |
3 files changed, 40 insertions, 50 deletions
diff --git a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt index ff85c00..c12a2c6 100644 --- a/src/main/kotlin/features/diana/AncestralSpadeSolver.kt +++ b/src/main/kotlin/features/diana/AncestralSpadeSolver.kt @@ -1,33 +1,30 @@ package moe.nea.firmament.features.diana import kotlin.time.Duration.Companion.seconds -import net.minecraft.particle.ParticleTypes -import net.minecraft.sound.SoundEvents -import net.minecraft.util.math.Vec3d +import net.minecraft.core.particles.ParticleTypes +import net.minecraft.sounds.SoundEvents +import net.minecraft.world.phys.Vec3 import moe.nea.firmament.annotations.Subscribe 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.events.subscription.SubscriptionOwner -import moe.nea.firmament.features.FirmamentFeature import moe.nea.firmament.util.MC import moe.nea.firmament.util.SBData import moe.nea.firmament.util.SkyBlockIsland -import moe.nea.firmament.util.SkyblockId import moe.nea.firmament.util.TimeMark import moe.nea.firmament.util.WarpUtil import moe.nea.firmament.util.render.RenderInWorldContext import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.skyblock.SkyBlockItems -object AncestralSpadeSolver : SubscriptionOwner { +object AncestralSpadeSolver { var lastDing = TimeMark.farPast() private set private val pitches = mutableListOf<Float>() - val particlePositions = mutableListOf<Vec3d>() - var nextGuess: Vec3d? = null + val particlePositions = mutableListOf<Vec3>() + var nextGuess: Vec3? = null private set private var lastTeleportAttempt = TimeMark.farPast() @@ -35,7 +32,11 @@ object AncestralSpadeSolver : SubscriptionOwner { fun isEnabled() = DianaWaypoints.TConfig.ancestralSpadeSolver && SBData.skyblockLocation == SkyBlockIsland.HUB - && MC.player?.inventory?.containsAny { it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE } == true // TODO: add a reactive property here + && MC.player?.inventory?.hasAnyMatching { + it.skyBlockId == SkyBlockItems.ANCESTRAL_SPADE || + it.skyBlockId == SkyBlockItems.ARCHAIC_SPADE || + it.skyBlockId == SkyBlockItems.DEIFIC_SPADE + } == true // TODO: add a reactive property here @Subscribe fun onKeyBind(event: WorldKeyboardEvent) { @@ -62,7 +63,7 @@ object AncestralSpadeSolver : SubscriptionOwner { @Subscribe fun onPlaySound(event: SoundReceiveEvent) { if (!isEnabled()) return - if (!SoundEvents.BLOCK_NOTE_BLOCK_HARP.matchesId(event.sound.value().id)) return + if (!SoundEvents.NOTE_BLOCK_HARP.`is`(event.sound.value().location)) return if (lastDing.passedTime() > 1.seconds) { particlePositions.clear() @@ -96,7 +97,7 @@ object AncestralSpadeSolver : SubscriptionOwner { .let { (a, _, b) -> b.subtract(a) } .normalize() - nextGuess = event.position.add(lastParticleDirection.multiply(soundDistanceEstimate)) + nextGuess = event.position.add(lastParticleDirection.scale(soundDistanceEstimate)) } @Subscribe @@ -106,13 +107,11 @@ object AncestralSpadeSolver : SubscriptionOwner { nextGuess?.let { tinyBlock(it, 1f, 0x80FFFFFF.toInt()) // TODO: replace this - color(1f, 1f, 0f, 1f) - tracer(it, lineWidth = 3f) + tracer(it, lineWidth = 3f, color = 0x80FFFFFF.toInt()) } if (particlePositions.size > 2 && lastDing.passedTime() < 10.seconds && nextGuess != null) { // TODO: replace this // TODO: add toggle - color(0f, 1f, 0f, 0.7f) - line(particlePositions) + line(particlePositions, color = 0x80FFFFFF.toInt()) } } } @@ -124,8 +123,4 @@ object AncestralSpadeSolver : SubscriptionOwner { pitches.clear() lastDing = TimeMark.farPast() } - - override val delegateFeature: FirmamentFeature - get() = DianaWaypoints - } diff --git a/src/main/kotlin/features/diana/DianaWaypoints.kt b/src/main/kotlin/features/diana/DianaWaypoints.kt index 6d87262..650e6f9 100644 --- a/src/main/kotlin/features/diana/DianaWaypoints.kt +++ b/src/main/kotlin/features/diana/DianaWaypoints.kt @@ -3,29 +3,29 @@ package moe.nea.firmament.features.diana import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.AttackBlockEvent import moe.nea.firmament.events.UseBlockEvent -import moe.nea.firmament.features.FirmamentFeature -import moe.nea.firmament.gui.config.ManagedConfig +import moe.nea.firmament.util.data.Config +import moe.nea.firmament.util.data.ManagedConfig -object DianaWaypoints : FirmamentFeature { - override val identifier get() = "diana" - override val config get() = TConfig +object DianaWaypoints { + val identifier get() = "diana" - object TConfig : ManagedConfig(identifier, Category.EVENTS) { - val ancestralSpadeSolver by toggle("ancestral-spade") { true } - val ancestralSpadeTeleport by keyBindingWithDefaultUnbound("ancestral-teleport") - val nearbyWaypoints by toggle("nearby-waypoints") { true } - } + @Config + object TConfig : ManagedConfig(identifier, Category.EVENTS) { + val ancestralSpadeSolver by toggle("ancestral-spade") { true } + val ancestralSpadeTeleport by keyBindingWithDefaultUnbound("ancestral-teleport") + val nearbyWaypoints by toggle("nearby-waypoints") { true } + } - @Subscribe - fun onBlockUse(event: UseBlockEvent) { - NearbyBurrowsSolver.onBlockClick(event.hitResult.blockPos) - } + @Subscribe + fun onBlockUse(event: UseBlockEvent) { + NearbyBurrowsSolver.onBlockClick(event.hitResult.blockPos) + } - @Subscribe - fun onBlockAttack(event: AttackBlockEvent) { - NearbyBurrowsSolver.onBlockClick(event.blockPos) - } + @Subscribe + fun onBlockAttack(event: AttackBlockEvent) { + NearbyBurrowsSolver.onBlockClick(event.blockPos) + } } diff --git a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt index 2fb4002..35af660 100644 --- a/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt +++ b/src/main/kotlin/features/diana/NearbyBurrowsSolver.kt @@ -2,22 +2,20 @@ package moe.nea.firmament.features.diana import me.shedaniel.math.Color import kotlin.time.Duration.Companion.seconds -import net.minecraft.particle.ParticleTypes -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.MathHelper -import net.minecraft.util.math.Position +import net.minecraft.core.particles.ParticleTypes +import net.minecraft.core.BlockPos +import net.minecraft.util.Mth +import net.minecraft.core.Position import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.ParticleSpawnEvent import moe.nea.firmament.events.ProcessChatEvent import moe.nea.firmament.events.WorldReadyEvent import moe.nea.firmament.events.WorldRenderLastEvent -import moe.nea.firmament.events.subscription.SubscriptionOwner -import moe.nea.firmament.features.FirmamentFeature import moe.nea.firmament.util.TimeMark import moe.nea.firmament.util.collections.mutableMapWithMaxSize import moe.nea.firmament.util.render.RenderInWorldContext.Companion.renderInWorld -object NearbyBurrowsSolver : SubscriptionOwner { +object NearbyBurrowsSolver { private val recentlyDugBurrows: MutableMap<BlockPos, TimeMark> = mutableMapWithMaxSize(20) @@ -65,7 +63,7 @@ object NearbyBurrowsSolver : SubscriptionOwner { fun onParticles(event: ParticleSpawnEvent) { if (!DianaWaypoints.TConfig.nearbyWaypoints) return - val position: BlockPos = event.position.toBlockPos().down() + val position: BlockPos = event.position.toBlockPos().below() if (wasRecentlyDug(position)) return @@ -134,11 +132,8 @@ object NearbyBurrowsSolver : SubscriptionOwner { burrows.remove(blockPos) lastBlockClick = blockPos } - - override val delegateFeature: FirmamentFeature - get() = DianaWaypoints } fun Position.toBlockPos(): BlockPos { - return BlockPos(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z)) + return BlockPos(Mth.floor(x()), Mth.floor(y()), Mth.floor(z())) } |
