diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-09 21:22:36 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-09 21:22:36 +0100 |
commit | ebacd8b4584b88efd531c82c0c686e41a095544f (patch) | |
tree | 0778481016d908c4eb50ab5eb864104249b99637 | |
parent | 0d79bb0769b92496c1b255a5cab71643372d4c25 (diff) | |
download | skyhanni-ebacd8b4584b88efd531c82c0c686e41a095544f.tar.gz skyhanni-ebacd8b4584b88efd531c82c0c686e41a095544f.tar.bz2 skyhanni-ebacd8b4584b88efd531c82c0c686e41a095544f.zip |
Added /desk shortcut in sb menu
3 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 8fb90ed9c..1c1617864 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -215,6 +215,7 @@ public class SkyHanniMod { loadModule(new GardenCustomKeybinds()); loadModule(new ChickenHeadTimer()); loadModule(new GardenOptimalSpeed()); + loadModule(new GardenDeskInSBMenu()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 58e014ce9..a288113ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -297,4 +297,9 @@ public class Garden { @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean public boolean plotPrice = true; + + @Expose + @ConfigOption(name = "Desk in Menu", desc = "Show a Desk button in the SkyBlock Menu. Opens the /desk command on click.") + @ConfigEditorBoolean + public boolean deskInSkyBlockMenu = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt new file mode 100644 index 000000000..fc060bad5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenDeskInSBMenu.kt @@ -0,0 +1,50 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.Garden +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.utils.NEUItems +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent +import io.github.moulberry.notenoughupdates.events.SlotClickEvent +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GardenDeskInSBMenu { + + private val config: Garden get() = SkyHanniMod.feature.garden + private var showItem = false + + private val item by lazy { + val neuItem = NEUItems.getItemStack("DOUBLE_PLANT") + Utils.createItemStack(neuItem.item, "§bDesk", "§7Click here to", "§7run §e/desk") + } + + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + showItem = GardenAPI.inGarden() && config.deskInSkyBlockMenu && event.inventoryName == "SkyBlock Menu" + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + showItem = false + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (showItem && event.slotNumber == 10) { + event.replaceWith(item) + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onStackClick(event: SlotClickEvent) { + if (showItem && event.slotId == 10) { + val thePlayer = Minecraft.getMinecraft().thePlayer + thePlayer.sendChatMessage("/desk") + } + } +}
\ No newline at end of file |