From f1930397ccfb9d953bbd93ace46508c487dd6579 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 8 Nov 2023 00:06:16 +0100 Subject: Added option to change the Blaze Slayer Dagger GUI positons. --- .../slayer/blaze/BlazeSlayerDaggerHelper.kt | 103 ++++----------------- 1 file changed, 17 insertions(+), 86 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index ce892f31f..0e9b9f8ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -12,23 +13,19 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision +import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import at.hannibal2.skyhanni.utils.getLorenzVec -import io.github.moulberry.moulconfig.internal.TextRenderUtils import net.minecraft.client.Minecraft -import net.minecraft.client.gui.ScaledResolution -import net.minecraft.client.renderer.GlStateManager import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class BlazeSlayerDaggerHelper { + private val config get() = SkyHanniMod.feature.slayer.blazes.hellion private var clientSideClicked = false - private var textTopLeft = "" - private var textTopRight = "" - private var textBottomLeft = "" - private var textBottomRight = "" + private var textTop = "" + private var textBottom = "" private var lastDaggerCheck = 0L private var lastNearestCheck = 0L @@ -58,10 +55,8 @@ class BlazeSlayerDaggerHelper { return } - textTopLeft = "" - textTopRight = "" - textBottomLeft = "" - textBottomRight = "" + textTop = "" + textBottom = "" } private fun setDaggerText(holding: Dagger) { @@ -71,10 +66,8 @@ class BlazeSlayerDaggerHelper { val first = Dagger.entries[SkyHanniMod.feature.slayer.blazes.hellion.firstDagger] val second = first.other() - textTopLeft = format(holding, true, first) - textTopRight = format(holding, true, second) - textBottomLeft = format(holding, false, first) - textBottomRight = format(holding, false, second) + textTop = format(holding, true, first) + " " + format(holding, true, second) + textBottom = format(holding, false, first) + " " + format(holding, false, second) } private fun findNearest(): HellionShield? { @@ -194,7 +187,7 @@ class BlazeSlayerDaggerHelper { } private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.blazes.hellion.daggers + return LorenzUtils.inSkyBlock && config.daggers } @SubscribeEvent @@ -242,75 +235,13 @@ class BlazeSlayerDaggerHelper { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - if (textTopLeft.isEmpty()) return - - if (Minecraft.getMinecraft().currentScreen != null) return - - val scaledResolution = ScaledResolution(Minecraft.getMinecraft()) - val width = scaledResolution.scaledWidth - val height = scaledResolution.scaledHeight - - val sizeFactor = (width.toFloat() / 960f).roundToPrecision(3) - - GlStateManager.enableBlend() - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) - val renderer = Minecraft.getMinecraft().fontRendererObj - - GlStateManager.pushMatrix() - GlStateManager.translate(((width / 2) / 1.18).toFloat(), (height / 3.8).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth( - textTopLeft, - renderer, - 0f, - 0f, - false, - (60f * sizeFactor).toInt(), - 0 - ) - GlStateManager.popMatrix() - - GlStateManager.pushMatrix() - GlStateManager.translate(((width / 2) * 1.18).toFloat(), (height / 3.8).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth( - textTopRight, - renderer, - 0f, - 0f, - false, - (60f * sizeFactor).toInt(), - 0 - ) - GlStateManager.popMatrix() - - GlStateManager.pushMatrix() - GlStateManager.translate(((width / 2) / 1.18).toFloat(), (height / 3.0).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth( - textBottomLeft, - renderer, - 0f, - 0f, - false, - (20f * sizeFactor).toInt(), - 0 - ) - GlStateManager.popMatrix() - - GlStateManager.pushMatrix() - GlStateManager.translate(((width / 2) * 1.18).toFloat(), (height / 3.0).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth( - textBottomRight, - renderer, - 0f, - 0f, - false, - (20f * sizeFactor).toInt(), - 0 - ) - GlStateManager.popMatrix() + + if (textTop == "") return + val currentScreen = Minecraft.getMinecraft().currentScreen + if (currentScreen != null && currentScreen !is GuiPositionEditor) return + + config.positionTop.renderString(textTop, posLabel = "Blaze Slayer Dagger Top") + config.positionBottom.renderString(textBottom, posLabel = "Blaze Slayer Dagger Bottom") } @SubscribeEvent -- cgit