diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-09 00:37:17 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-09 00:37:17 +0200 |
commit | b6e4599d4454bc227886fafd0deab5ced882b97c (patch) | |
tree | becfa9afb79190031c159f5d5d302d9599e451d6 /src/main/java/at | |
parent | 0d3c6f6c95fe3574d1da5d75f344dac459a3b241 (diff) | |
download | skyhanni-b6e4599d4454bc227886fafd0deab5ced882b97c.tar.gz skyhanni-b6e4599d4454bc227886fafd0deab5ced882b97c.tar.bz2 skyhanni-b6e4599d4454bc227886fafd0deab5ced882b97c.zip |
adding a button on pause menu
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/lorenz/mod/LorenzMod.java | 4 | ||||
-rw-r--r-- | src/main/java/at/lorenz/mod/config/Features.java | 6 | ||||
-rw-r--r-- | src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt | 42 |
3 files changed, 51 insertions, 1 deletions
diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java index 8f167e8c9..9ff03cec2 100644 --- a/src/main/java/at/lorenz/mod/LorenzMod.java +++ b/src/main/java/at/lorenz/mod/LorenzMod.java @@ -8,6 +8,7 @@ import at.lorenz.mod.chat.PlayerChatFilter; import at.lorenz.mod.config.Features; import at.lorenz.mod.dungeon.DungeonChatFilter; import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks; +import at.lorenz.mod.misc.ButtonOnPause; import at.lorenz.mod.misc.CurrentPetDisplay; import at.lorenz.mod.misc.ExpBottleOnGroundHider; import com.google.gson.Gson; @@ -59,6 +60,9 @@ public class LorenzMod { Commands.init(); + MinecraftForge.EVENT_BUS.register(new ButtonOnPause()); + + // MinecraftForge.EVENT_BUS.register(new LeaderboardGetter()); // MinecraftForge.EVENT_BUS.register(new SeasonDateHandler()); // MinecraftForge.EVENT_BUS.register(new LocationHandler()); diff --git a/src/main/java/at/lorenz/mod/config/Features.java b/src/main/java/at/lorenz/mod/config/Features.java index 43843df40..327aa2bcb 100644 --- a/src/main/java/at/lorenz/mod/config/Features.java +++ b/src/main/java/at/lorenz/mod/config/Features.java @@ -68,7 +68,6 @@ public class Features { @ConfigEditorAccordion(id = 1) public boolean filterTypes = false; - @Expose @ConfigOption(name = "HyPixel Hub", desc = "Block messages outside SkyBlock in the HyPixel lobby: player joins, loot boxes, prototype lobby messages, radiating generosity and HyPixel tournaments.") @ConfigEditorBoolean @@ -186,6 +185,11 @@ public class Features { @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.") @ConfigEditorBoolean public boolean hideExpBottles = false; + + @Expose + @ConfigOption(name = "Config Button", desc = "Adds a button to the pause menu to configure the Lorenz mod.") + @ConfigEditorBoolean + public boolean configButtonOnPause = true; } public static class Test { diff --git a/src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt b/src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt new file mode 100644 index 000000000..9fe540ae9 --- /dev/null +++ b/src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt @@ -0,0 +1,42 @@ +package at.lorenz.mod.misc + +import at.lorenz.mod.LorenzMod +import com.thatgravyboat.skyblockhud_2.config.SBHConfigEditor +import com.thatgravyboat.skyblockhud_2.core.GuiScreenElementWrapper +import net.minecraft.client.gui.GuiButton +import net.minecraft.client.gui.GuiIngameMenu +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ButtonOnPause { + private val buttonId = System.nanoTime().toInt() + + @SubscribeEvent + fun onGuiAction(event: GuiScreenEvent.ActionPerformedEvent.Post) { + if (LorenzMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu && event.button.id == buttonId) { + LorenzMod.screenToOpen = GuiScreenElementWrapper(SBHConfigEditor(LorenzMod.feature)) + } + } + + @SubscribeEvent + fun onGuiInitPost(event: GuiScreenEvent.InitGuiEvent.Post) { + if (LorenzMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu) { + val x = event.gui.width - 105 + val x2 = x + 100 + var y = event.gui.height - 22 + var y2 = y + 20 + val sorted = event.buttonList.sortedWith { a, b -> b.yPosition + b.height - a.yPosition + a.height } + for (button in sorted) { + val otherX = button.xPosition + val otherX2 = button.xPosition + button.width + val otherY = button.yPosition + val otherY2 = button.yPosition + button.height + if (otherX2 > x && otherX < x2 && otherY2 > y && otherY < y2) { + y = otherY - 20 - 2 + y2 = y + 20 + } + } + event.buttonList.add(GuiButton(buttonId, x, 0.coerceAtLeast(y), 100, 20, "Lorenz Mod")) + } + } +}
\ No newline at end of file |