aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-08-26 14:15:06 +0200
committerGitHub <noreply@github.com>2024-08-26 14:15:06 +0200
commit46bc7830c80ccb068a4cef62458dc5751dac07d3 (patch)
treefb3f1b1ea49cdc338f9c654b73bfee966e837b47 /src
parent4247a5c2f1d62ebd2a84c74a3a34287905084278 (diff)
downloadskyhanni-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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/XPBarConfig.java31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/MovableXpBar.kt43
3 files changed, 79 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java
index 1c3f92b47..6355857f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java
@@ -67,6 +67,11 @@ public class GUIConfig {
public HotbarConfig hotbar = new HotbarConfig();
@Expose
+ @ConfigOption(name = "Xp Bar", desc = "Settings for adjusting the xp bar")
+ @Accordion
+ public XPBarConfig xpBar = new XPBarConfig();
+
+ @Expose
@ConfigOption(name = "Marked Players", desc = "Players that got marked with §e/shmarkplayer§7.")
@Accordion
public MarkedPlayerConfig markedPlayers = new MarkedPlayerConfig();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/XPBarConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/XPBarConfig.java
new file mode 100644
index 000000000..bd2f2cac9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/XPBarConfig.java
@@ -0,0 +1,31 @@
+package at.hannibal2.skyhanni.config.features.gui;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.core.config.Position;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class XPBarConfig {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Allows for moving and scaling the Xp bar in the SkyHanni GUI Editor.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @ConfigOption(name = "§cNotice", desc = "This option will be §c§lincompatible §r§7with mods that change the xp bar. Eg: §eApec§7.")
+ @ConfigEditorInfoText
+ public String notice = "";
+
+ @Expose
+ @ConfigLink(owner = XPBarConfig.class, field = "enabled")
+ public Position position = new Position(20, 20);
+
+ @Expose
+ @ConfigOption(name = "Show Outside Skyblock", desc = "Shows the XP bar outside of SkyBlock.")
+ @ConfigEditorBoolean
+ public boolean showOutsideSkyblock = false;
+}
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
+}