aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-05-29 23:42:34 +0200
committerGitHub <noreply@github.com>2024-05-29 23:42:34 +0200
commit29ddd9d05a59c9540869c0f96648cda8ad9364df (patch)
tree8c866680fdee6ce21379d670f601a462129812b9 /src/main/java/at/hannibal2/skyhanni
parent3abd085de6a31c24a92b05012a3b81e686065edc (diff)
downloadskyhanni-29ddd9d05a59c9540869c0f96648cda8ad9364df.tar.gz
skyhanni-29ddd9d05a59c9540869c0f96648cda8ad9364df.tar.bz2
skyhanni-29ddd9d05a59c9540869c0f96648cda8ad9364df.zip
Feature: Moveable and Scaleable Hotbar (#1903)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-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/HotbarConfig.java31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt41
4 files changed, 79 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 0374024e0..794a7a568 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -251,6 +251,7 @@ import at.hannibal2.skyhanni.features.garden.visitor.NPCVisitorFix
import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI
import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener
import at.hannibal2.skyhanni.features.garden.visitor.VisitorRewardWarning
+import at.hannibal2.skyhanni.features.gui.MovableHotBar
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.features.gui.quiver.QuiverDisplay
@@ -532,6 +533,7 @@ class SkyHanniMod {
loadModule(RenderData())
loadModule(GardenCropMilestones)
loadModule(GardenCropMilestonesCommunityFix)
+ loadModule(MovableHotBar())
loadModule(GardenCropUpgrades)
loadModule(VisitorListener())
loadModule(VisitorRewardWarning())
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 1309780a8..b259fd26d 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
@@ -62,6 +62,11 @@ public class GUIConfig {
public DiscordRPCConfig discordRPC = new DiscordRPCConfig();
@Expose
+ @ConfigOption(name = "Hotbar", desc = "Settings for adjusting the hotbar")
+ @Accordion
+ public HotbarConfig hotbar = new HotbarConfig();
+
+ @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/HotbarConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/HotbarConfig.java
new file mode 100644
index 000000000..e13c18a8d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/HotbarConfig.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 HotbarConfig {
+
+ @Expose
+ @ConfigOption(name = "Editable", desc = "Adds the hotbar to the gui editor. Allows for moving and scaling of the hotbar.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean editable = false;
+
+ @ConfigOption(name = "§cNotice", desc = "This option will be §c§lincompatible §r§7with mods that change the hotbar. Eg: §eApec§7.")
+ @ConfigEditorInfoText
+ public String notice = "";
+
+ @Expose
+ @ConfigLink(owner = HotbarConfig.class, field = "editable")
+ public Position hotbar = new Position(20, 20);
+
+ @Expose
+ @ConfigOption(name = "Show Outside Skyblock", desc = "Enables the hotbar to be edited even outside of SkyBlock.")
+ @ConfigEditorBoolean
+ public boolean showOutsideSkyblock = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt
new file mode 100644
index 000000000..37a86eb22
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt
@@ -0,0 +1,41 @@
+package at.hannibal2.skyhanni.features.gui
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.GuiEditManager
+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.SubscribeEvent
+
+class MovableHotBar {
+
+ private val config get() = SkyHanniMod.feature.gui.hotbar
+
+ private var post = false
+
+ @SubscribeEvent
+ fun onRenderHotbar(event: RenderGameOverlayEvent.Pre) {
+ if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR || !isEnabled()) return
+ post = true
+ GlStateManager.pushMatrix()
+ val scaled = event.resolution
+ val x = scaled.scaledWidth / 2 - 91
+ val y = scaled.scaledHeight - 22
+ config.hotbar.transform()
+ GlStateManager.translate(-x.toFloat(), -y.toFloat(), 0f) // Must be after transform to work with scaling
+ GuiEditManager.add(config.hotbar, "Hotbar", 182 - 1, 22 - 1) // -1 since the editor for some reason add +1
+ }
+
+ @SubscribeEvent
+ fun onRenderHotbar(event: RenderGameOverlayEvent.Post) {
+ if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR || !post) return
+ GlStateManager.popMatrix()
+ post = false
+ }
+
+ fun isEnabled(): Boolean =
+ (LorenzUtils.inSkyBlock || (Minecraft.getMinecraft().thePlayer != null && config.showOutsideSkyblock))
+ && config.editable
+}