diff options
author | VeritasDL <121319869+VeritasDL@users.noreply.github.com> | 2024-05-14 18:06:55 -0400 |
---|---|---|
committer | VeritasDL <121319869+VeritasDL@users.noreply.github.com> | 2024-05-14 19:16:00 -0400 |
commit | 713c5c215622f1448d1bbd8e1d47effe34d47a00 (patch) | |
tree | 4761d6615fa2e6a326cdd0fd3d82264b7312eaad /src/main/java/de/hysky | |
parent | df8cd71d04ae9d64240472912ff929724047302f (diff) | |
download | Skyblocker-713c5c215622f1448d1bbd8e1d47effe34d47a00.tar.gz Skyblocker-713c5c215622f1448d1bbd8e1d47effe34d47a00.tar.bz2 Skyblocker-713c5c215622f1448d1bbd8e1d47effe34d47a00.zip |
Machinika: Museum
Diffstat (limited to 'src/main/java/de/hysky')
4 files changed, 165 insertions, 21 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java index 64c67417..e6543daf 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java @@ -25,6 +25,15 @@ public class QuickNavigationCategory { .controller(ConfigUtils::createBooleanController) .build()) + //Enable Extended Quick Nav Buttons + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.enableExtendedQuickNav")) + .binding(defaults.quickNav.enableExtendedQuickNav, + () -> config.quickNav.enableExtendedQuickNav, + newValue -> config.quickNav.enableExtendedQuickNav = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + //Button 1 .group(OptionGroup.createBuilder() .name(Text.translatable("skyblocker.config.quickNav.button", 1)) @@ -613,6 +622,103 @@ public class QuickNavigationCategory { .build()) .build()) + //Button 13 + .group(OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button", 13)) + .collapsed(true) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.render")) + .binding(defaults.quickNav.button13.render, + () -> config.quickNav.button13.render, + newValue -> config.quickNav.button13.render = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) + .binding(defaults.quickNav.button13.item.id, + () -> config.quickNav.button13.item.id, + newValue -> config.quickNav.button13.item.id = newValue) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.<Integer>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) + .binding(defaults.quickNav.button13.item.count, + () -> config.quickNav.button13.item.count, + newValue -> config.quickNav.button13.item.count = newValue) + .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.components")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.quickNav.button.item.components.@Tooltip"))) + .binding(defaults.quickNav.button13.item.components, + () -> config.quickNav.button13.item.components, + newValue -> config.quickNav.button13.item.components = newValue) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) + .binding(defaults.quickNav.button13.uiTitle, + () -> config.quickNav.button13.uiTitle, + newValue -> config.quickNav.button13.uiTitle = newValue) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) + .binding(defaults.quickNav.button13.clickEvent, + () -> config.quickNav.button13.clickEvent, + newValue -> config.quickNav.button13.clickEvent = newValue) + .controller(StringControllerBuilder::create) + .build()) + .build()) + + //Button 14 + .group(OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button", 14)) + .collapsed(true) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.render")) + .binding(defaults.quickNav.button14.render, + () -> config.quickNav.button14.render, + newValue -> config.quickNav.button14.render = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) + .binding(defaults.quickNav.button14.item.id, + () -> config.quickNav.button14.item.id, + newValue -> config.quickNav.button14.item.id = newValue) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.<Integer>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) + .binding(defaults.quickNav.button14.item.count, + () -> config.quickNav.button14.item.count, + newValue -> config.quickNav.button14.item.count = newValue) + .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.components")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.quickNav.button.item.components.@Tooltip"))) + .binding(defaults.quickNav.button14.item.components, + () -> config.quickNav.button14.item.components, + newValue -> config.quickNav.button14.item.components = newValue) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) + .binding(defaults.quickNav.button14.uiTitle, + () -> config.quickNav.button14.uiTitle, + newValue -> config.quickNav.button14.uiTitle = newValue) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.<String>createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) + .binding(defaults.quickNav.button14.clickEvent, + () -> config.quickNav.button14.clickEvent, + newValue -> config.quickNav.button14.clickEvent = newValue) + .controller(StringControllerBuilder::create) + .build()) + .build()) .build(); } } diff --git a/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java index ba863e33..173d2532 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java @@ -5,6 +5,8 @@ import dev.isxander.yacl3.config.v2.api.SerialEntry; public class QuickNavigationConfig { @SerialEntry public boolean enableQuickNav = true; + @SerialEntry + public boolean enableExtendedQuickNav = true; @SerialEntry public QuickNavItem button1 = new QuickNavItem(true, new ItemData("diamond_sword"), "Your Skills", "/skills"); @@ -68,6 +70,12 @@ public class QuickNavigationConfig { @SerialEntry public QuickNavItem button12 = new QuickNavItem(true, new ItemData("crafting_table"), "Craft Item", "/craft"); + @SerialEntry + public QuickNavItem button13 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;-562285948,532499670,-1705302742,775653035],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmZlMmRjZGE0MWVjM2FmZjhhZjUwZjI3MmVjMmUwNmE4ZjUwOWUwZjgwN2YyMzU1YTFmNWEzM2MxYjY2ZTliNCJ9fX0=\"}]}]"), "Bazaar .*", "/bz"); + + @SerialEntry + public QuickNavItem button14 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;-562285948,532499670,-1705302742,775653035],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzFlNDBmNDAyOTgxMzAzZmM4NTA4ZDkyMThkNGE3MzdhYzkzMTc2NmI4NTI4MWY5NDg5ZGI1OTA4OTU3ZGMyMiJ9fX0=\"}]}]"), "Auction House", "/ah"); + public static class QuickNavItem { public QuickNavItem(Boolean render, ItemData itemData, String uiTitle, String clickEvent) { this.render = render; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java index a6adf66b..2c9d8305 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -51,6 +51,10 @@ public class QuickNav { if (data.button10.render) buttons.add(parseButton(data.button10, screenTitle, 9)); if (data.button11.render) buttons.add(parseButton(data.button11, screenTitle, 10)); if (data.button12.render) buttons.add(parseButton(data.button12, screenTitle, 11)); + if (SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + if (data.button13.render) buttons.add(parseButton(data.button13, screenTitle, 12)); + if (data.button14.render) buttons.add(parseButton(data.button14, screenTitle, 13)); + } } catch (CommandSyntaxException e) { LOGGER.error("[Skyblocker] Failed to initialize Quick Nav Button", e); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java index 7db78590..516aed32 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -25,18 +26,24 @@ public class QuickNavButton extends ClickableWidget { /** * Checks if the current tab is a top tab based on its index. + * * @return true if the index is less than 6, false otherwise. */ private boolean isTopTab() { - return index < 6; + if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + return index < 6; + } else { + return index < 7; + } } /** * Constructs a new QuickNavButton with the given parameters. - * @param index the index of the button. + * + * @param index the index of the button. * @param toggled the toggled state of the button. * @param command the command to execute when the button is clicked. - * @param icon the icon to display on the button. + * @param icon the icon to display on the button. */ public QuickNavButton(int index, boolean toggled, String command, ItemStack icon) { super(0, 0, 26, 32, Text.empty()); @@ -49,18 +56,24 @@ public class QuickNavButton extends ClickableWidget { private void updateCoordinates() { Screen screen = MinecraftClient.getInstance().currentScreen; if (screen instanceof HandledScreen<?> handledScreen) { - int x = ((HandledScreenAccessor)handledScreen).getX(); - int y = ((HandledScreenAccessor)handledScreen).getY(); - int h = ((HandledScreenAccessor)handledScreen).getBackgroundHeight(); + int x = ((HandledScreenAccessor) handledScreen).getX(); + int y = ((HandledScreenAccessor) handledScreen).getY(); + int h = ((HandledScreenAccessor) handledScreen).getBackgroundHeight(); if (h > 166) --h; // why is this even a thing - this.setX(x + this.index % 6 * 26 + 4); - this.setY(this.index < 6 ? y - 26 : y + h - 4); + if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + this.setX(x + this.index % 6 * 26 + 4); + this.setY(this.index < 6 ? y - 26 : y + h - 4); + } else { + this.setX(x + this.index % 7 * 25); + this.setY(this.index < 7 ? y - 25 : y + h - 4); + } } } /** * Handles click events. If the button is not currently toggled, * it sets the toggled state to true and sends a message with the command after cooldown. + * * @param mouseX the x-coordinate of the mouse click * @param mouseY the y-coordinate of the mouse click */ @@ -78,9 +91,10 @@ public class QuickNavButton extends ClickableWidget { * The method first updates the coordinates of the button, * then calculates appropriate values for rendering based on its current state, * and finally draws both the background and icon of the button on screen. + * * @param context the context in which to render the button - * @param mouseX the x-coordinate of the mouse cursor - * @param mouseY the y-coordinate of the mouse cursor + * @param mouseX the x-coordinate of the mouse cursor + * @param mouseY the y-coordinate of the mouse cursor */ @Override public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { @@ -94,19 +108,31 @@ public class QuickNavButton extends ClickableWidget { // Render the button texture int y = this.getY(); - if (this.toggled) { - if (this.index < 6) y -= 2; - } else { - y += (this.index >= 6) ? 4 : -2; - } - int height = this.height - ((this.toggled ) ? 0 : 4); + if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + if (this.toggled) { + if (this.index < 6) y -= 2; + } else { + y += (this.index >= 6) ? 4 : -2; + } + int height = this.height - ((this.toggled) ? 0 : 4); - context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height); - - // Render the button icon - int yOffset = !this.toggled && this.index < 6 ? 1 : 0; - context.drawItem(this.icon, this.getX() + 5, this.getY() + 6 + yOffset); + context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height); + // Render the button icon + int yOffset = !this.toggled && this.index < 6 ? 1 : 0; + context.drawItem(this.icon, this.getX() + 5, this.getY() + 6 + yOffset); + } else { + if (this.toggled) { + if (this.index < 7) y -= 2; + } else { + y += (this.index >= 7) ? 4 : -2; + } + int height = this.height - ((this.toggled) ? 0 : 4); + context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width - 1, height); + // Render the button icon + int yOffset = !this.toggled && this.index < 7 ? 1 : 0; + context.drawItem(this.icon, this.getX() + 4, this.getY() + 6 + yOffset); + } RenderSystem.enableDepthTest(); } |