diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-08-23 10:50:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-23 10:50:42 +0200 |
commit | 795e30bcecb1f72a9eb32331867d20f29554505a (patch) | |
tree | 75d691dd6c551ac56c88c396092a8c1d27c6509d /src/main/java/at/hannibal2 | |
parent | 7d45133463f375252ba3e7e269cf1d27162aa1ee (diff) | |
download | skyhanni-795e30bcecb1f72a9eb32331867d20f29554505a.tar.gz skyhanni-795e30bcecb1f72a9eb32331867d20f29554505a.tar.bz2 skyhanni-795e30bcecb1f72a9eb32331867d20f29554505a.zip |
Fix: Patcher Breaking Lines (#2387)
Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
4 files changed, 83 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 6843d0948..beb7f2225 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -218,6 +218,15 @@ public class MiscConfig { @Expose @ConfigOption( + name = "Fix Patcher Lines", + desc = "Suggest in chat to disable Patcher's `parallax fix` that breaks SkyHanni's line from middle of player to somewhere else." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean fixPatcherLines = true; + + @Expose + @ConfigOption( name = "Time In Limbo", desc = "Show the time since you entered the limbo.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherFixes.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherFixes.kt new file mode 100644 index 000000000..a7d844e4e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherFixes.kt @@ -0,0 +1,47 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.OtherModsSettings +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds + +object PatcherFixes { + private val config get() = SkyHanniMod.feature.misc + + private var lastCheck = SimpleTimeMark.farPast() + private var lastChatMessage = SimpleTimeMark.farPast() + + fun onPlayerEyeLine() { + if (!isEnabled()) return + if (lastCheck.passedSince() < 5.seconds) return + lastCheck = SimpleTimeMark.now() + + val patcher = OtherModsSettings.patcher() + if (!patcher.getBoolean("parallaxFix")) return + + if (lastChatMessage.passedSince() < 3.minutes) return + lastChatMessage = SimpleTimeMark.now() + + ChatUtils.clickToActionOrDisable( + "§cPatcher's Parallax Fix breaks SkyHanni's line rendering!", + config::fixPatcherLines, + "disable this option in Patcher", + action = { tryFix() }, + ) + } + + private fun tryFix() { + val patcher = OtherModsSettings.patcher() + if (patcher.getBoolean("parallaxFix")) { + patcher.setBoolean("parallaxFix", false) + ChatUtils.chat("§aDisabled Patcher's Parallax Fix! SkyHanni's lines should now work correctly.") + } else { + ChatUtils.userError("Patcher's Parallax is already disabled!") + } + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && config.fixPatcherLines +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OtherModsSettings.kt b/src/main/java/at/hannibal2/skyhanni/utils/OtherModsSettings.kt new file mode 100644 index 000000000..2cf9c6f6d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/OtherModsSettings.kt @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.utils + +import java.lang.reflect.Field + +class OtherModsSettings(val modConfigPath: String) { + + companion object { + fun patcher(): OtherModsSettings = getModPath("club.sk1er.patcher.config.PatcherConfig") + + private fun getModPath(modConfigPath: String): OtherModsSettings = OtherModsSettings(modConfigPath) + } + + fun getBoolean(optionPath: String): Boolean = getOption(optionPath)?.get(null) as? Boolean ?: false + + fun setBoolean(optionPath: String, value: Boolean) { + getOption(optionPath)?.set(null, value) + } + + private fun getOption(optionPath: String): Field? = + try { + Class.forName(modConfigPath).getField(optionPath) + } catch (e: Throwable) { + null + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 9ff6053e7..f4a57cb18 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderItemEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RenderGuiItemOverlayEvent +import at.hannibal2.skyhanni.features.misc.PatcherFixes import at.hannibal2.skyhanni.features.misc.RoundedRectangleOutlineShader import at.hannibal2.skyhanni.features.misc.RoundedRectangleShader import at.hannibal2.skyhanni.features.misc.RoundedTextureShader @@ -1132,6 +1133,7 @@ object RenderUtils { fun LorenzRenderWorldEvent.exactPlayerEyeLocation(): LorenzVec { val player = Minecraft.getMinecraft().thePlayer val add = if (player.isSneaking) LorenzVec(0.0, 1.54, 0.0) else LorenzVec(0.0, 1.62, 0.0) + PatcherFixes.onPlayerEyeLine() return exactLocation(player) + add } |