diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2023-07-05 12:29:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-05 12:29:49 +0200 |
| commit | c4092f9f36ef2d6a1914ee5ef606522d35e14cdc (patch) | |
| tree | 5f606fa38d17f3e2471e75060c06acb9f65a2c81 /src/main/java/at/hannibal2/skyhanni/features/rift | |
| parent | 5bedd8978dc05f60ef752a95a2062e99be41281c (diff) | |
| download | skyhanni-c4092f9f36ef2d6a1914ee5ef606522d35e14cdc.tar.gz skyhanni-c4092f9f36ef2d6a1914ee5ef606522d35e14cdc.tar.bz2 skyhanni-c4092f9f36ef2d6a1914ee5ef606522d35e14cdc.zip | |
mirror verse jump and run (#265)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Roman / Linnea Gräf <nea@nea.moe>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
4 files changed, 147 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt index 73ebd0e3b..632129d11 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt @@ -123,5 +123,5 @@ object CruxTalismanDisplay { data class Crux(val name: String, val tier: String, val progress: String, val maxed: Boolean) - fun isEnabled() = RiftAPI.inRift() && config.enabled + fun isEnabled() = RiftAPI.inRift() && config.enabled && LorenzUtils.skyBlockArea != "Mirrorverse" }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt index 6ea866311..a7d40580b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/EnigmaSoulWaypoints.kt @@ -26,7 +26,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object EnigmaSoulWaypoints { private val config get() = SkyHanniMod.feature.rift.enigmaSoulWaypoints private var inInventory = false - private val soulLocations = mutableMapOf<String, LorenzVec>() + private var soulLocations = mapOf<String, LorenzVec>() private val trackedSouls = mutableListOf<String>() private val inventoryUnfound = mutableListOf<String>() private var adding = true @@ -144,10 +144,11 @@ object EnigmaSoulWaypoints { fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant<EnigmaSoulsJson>("EnigmaSouls") ?: return val areas = data.areas ?: error("'areas' is null in EnigmaSouls!") - soulLocations.clear() - for ((area, locations) in areas) { - for (location in locations) { - soulLocations[location.name] = location.position + soulLocations = buildMap { + for ((area, locations) in areas) { + for (location in locations) { + this[location.name] = location.position + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt index 6bffa8a80..42188244e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftTimer.kt @@ -84,6 +84,7 @@ class RiftTimer { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return + if (LorenzUtils.skyBlockArea == "Mirrorverse") return config.timerPosition.renderStrings(display, posLabel = "Rift Timer") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftUpsideDownParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftUpsideDownParkour.kt new file mode 100644 index 000000000..721c51654 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftUpsideDownParkour.kt @@ -0,0 +1,139 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LocationUtils.playerLocation +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox +import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock +import at.hannibal2.skyhanni.utils.jsonobjects.ParkourJson +import at.hannibal2.skyhanni.utils.jsonobjects.ParkourJson.ShortCut +import net.minecraft.client.Minecraft +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color +import kotlin.time.Duration.Companion.seconds + +class RiftUpsideDownParkour { + private val config get() = SkyHanniMod.feature.rift.mirrorVerse.upsideDownParkour + private var locations = emptyList<LorenzVec>() + private var shortCuts = emptyList<ShortCut>() + private var current = -1 + private var visible = false + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<ParkourJson>("RiftUpsideDownParkour") ?: return + locations = data.locations + shortCuts = data.shortCuts + } + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!isEnabled()) return + if (!config.hidePlayers) return + + if (current != -1) { + event.isCanceled = true + } + } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!isEnabled()) return + + if (event.message == "§c§lOH NO! THE LAVA OOFED YOU BACK TO THE START!") { + current = -1 + visible = false + } + } + + private val lookAhead get() = config.lookAhead + 1 + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!isEnabled()) return + + if (current == locations.size - 1) visible = false + + val distanceToPlayer = locations.first().distanceToPlayer() + if (distanceToPlayer < 2) { + visible = true + } else if (distanceToPlayer > 15) { + if (current < 1) { + visible = false + } + } + + if (!visible) return + + for ((index, location) in locations.withIndex()) { + if (location.distanceToPlayer() < 2) { + if (Minecraft.getMinecraft().thePlayer.onGround) { + current = index + } + } + } + if (current < 0) return + + val inProgressVec = getInProgressPair().toSingletonListOrEmpty() + for ((prev, next) in locations.asSequence().withIndex().zipWithNext().drop(current) + .take(lookAhead - 1) + inProgressVec) { + event.draw3DLine(prev.value, next.value, colorForIndex(prev.index), 5, false, colorForIndex(next.index)) + } + val nextShortcuts = current until current + lookAhead + for (shortCut in shortCuts) { + if (shortCut.from in nextShortcuts && shortCut.to in locations.indices) { + event.draw3DLine(locations[shortCut.from], locations[shortCut.to], Color.RED, 3, false) + event.drawFilledBoundingBox(axisAlignedBB(locations[shortCut.to]), Color.RED, 1f) + event.drawDynamicText(locations[shortCut.to].add(-0.5, 1.0, -0.5), "§cShortcut", 2.5) + } + + } + for ((index, location) in locations.asSequence().withIndex().drop(current) + .take(lookAhead) + inProgressVec.map { it.second }) { + event.drawFilledBoundingBox(axisAlignedBB(location), colorForIndex(index), 1f) + } + } + + private fun getInProgressPair(): Pair<IndexedValue<LorenzVec>, IndexedValue<LorenzVec>>? { + if (current < 0 || current + lookAhead >= locations.size) return null + val currentPosition = locations[current] + val nextPosition = locations[current + 1] + val lookAheadStart = locations[current + lookAhead - 1] + val lookAheadEnd = locations[current + lookAhead] + if (playerLocation().distance(nextPosition) > currentPosition.distance(nextPosition)) return null + return Pair( + IndexedValue(current + lookAhead - 1, lookAheadStart), + IndexedValue( + current + lookAhead, lookAheadStart.add( + lookAheadEnd.subtract(lookAheadStart) + .scale(playerLocation().distance(currentPosition) / currentPosition.distance(nextPosition)) + ) + ) + ) + } + + private fun axisAlignedBB(loc: LorenzVec) = loc.add(-1.0, 0.0, -1.0).boundingToOffset(2, -1, 2).expandBlock() + + private fun colorForIndex(index: Int) = if (config.rainbowColor) { + RenderUtils.chromaColor(4.seconds, offset = -index / 12f, brightness = 0.7f) + } else { + config.monochromeColor.toChromaColor() + } + + fun isEnabled() = RiftAPI.inRift() && LorenzUtils.skyBlockArea == "Mirrorverse" && config.enabled +} + +private fun <T : Any> T?.toSingletonListOrEmpty(): List<T> { + if (this == null) return emptyList() + return listOf(this) +} |
