diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-08-26 14:15:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 14:15:06 +0200 |
commit | 46bc7830c80ccb068a4cef62458dc5751dac07d3 (patch) | |
tree | fb3f1b1ea49cdc338f9c654b73bfee966e837b47 /src/main/java/at/hannibal2/skyhanni/features | |
parent | 4247a5c2f1d62ebd2a84c74a3a34287905084278 (diff) | |
download | skyhanni-46bc7830c80ccb068a4cef62458dc5751dac07d3.tar.gz skyhanni-46bc7830c80ccb068a4cef62458dc5751dac07d3.tar.bz2 skyhanni-46bc7830c80ccb068a4cef62458dc5751dac07d3.zip |
Feature: Editable Xp Bar (#1944)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/gui/MovableXpBar.kt | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/MovableXpBar.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/MovableXpBar.kt new file mode 100644 index 000000000..4c9f59e12 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/MovableXpBar.kt @@ -0,0 +1,43 @@ +package at.hannibal2.skyhanni.features.gui + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.GuiEditManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.transform +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object MovableXpBar { + + private val config get() = SkyHanniMod.feature.gui.xpBar + + private var post = false + + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onRenderXpBar(event: RenderGameOverlayEvent.Pre) { + if (event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE || !isEnabled()) return + post = true + GlStateManager.pushMatrix() + val scaled = event.resolution + val x = scaled.scaledWidth / 2 - 91 + val y = scaled.scaledHeight - 29 + config.position.transform() + GlStateManager.translate(-x.toFloat(), -y.toFloat(), 0f) // Must be after transform to work with scaling + GuiEditManager.add(config.position, "Xp Bar", 182 - 1, 5 - 1) // -1 since the editor for some reason add +1 + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + fun onRenderXpBar(event: RenderGameOverlayEvent.Post) { + if (event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE || !post) return + GlStateManager.popMatrix() + post = false + } + + private fun isEnabled() = (LorenzUtils.inSkyBlock || (Minecraft.getMinecraft().thePlayer != null && config.showOutsideSkyblock)) && + config.enabled +} |