diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/rift')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/RiftLavaMazeParkour.kt | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftLavaMazeParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftLavaMazeParkour.kt new file mode 100644 index 000000000..20029f9b7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftLavaMazeParkour.kt @@ -0,0 +1,75 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor +import at.hannibal2.skyhanni.utils.ParkourHelper +import at.hannibal2.skyhanni.utils.jsonobjects.ParkourJson +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftLavaMazeParkour { + private val config get() = SkyHanniMod.feature.rift.mirrorVerse.lavaMazeConfig + private var parkourHelper: ParkourHelper? = null + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<ParkourJson>("RiftLavaMazeParkour") ?: return + parkourHelper = ParkourHelper( + data.locations, + data.shortCuts, + platformSize = 1.0, + detectionRange = 1.0 + ) + updateConfig() + } + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!isEnabled()) return + if (!config.hidePlayers) return + + parkourHelper?.let { + if (it.inParkour()) { + event.isCanceled = true + } + } + } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!isEnabled()) return + + if (event.message == "§c§lEEK! THE LAVA OOFED YOU!") { + parkourHelper?.reset() + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + LorenzUtils.onToggle(config.rainbowColor, config.monochromeColor, config.lookAhead) { + updateConfig() + } + } + + private fun updateConfig() { + parkourHelper?.run { + rainbowColor = config.rainbowColor.get() + monochromeColor = config.monochromeColor.get().toChromaColor() + lookAhead = config.lookAhead.get() + 1 + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!isEnabled()) return + + parkourHelper?.render(event) + } + + fun isEnabled() = RiftAPI.inRift() && LorenzUtils.skyBlockArea == "Mirrorverse" && config.enabled +} |