From 713c5c215622f1448d1bbd8e1d47effe34d47a00 Mon Sep 17 00:00:00 2001 From: VeritasDL <121319869+VeritasDL@users.noreply.github.com> Date: Tue, 14 May 2024 18:06:55 -0400 Subject: [PATCH 01/10] Machinika: Museum --- .../categories/QuickNavigationCategory.java | 106 ++++++++++++++++++ .../config/configs/QuickNavigationConfig.java | 8 ++ .../skyblock/quicknav/QuickNav.java | 4 + .../skyblock/quicknav/QuickNavButton.java | 68 +++++++---- .../assets/skyblocker/lang/en_us.json | 1 + 5 files changed, 166 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 64c6741704..e6543daff7 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 static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) + //Enable Extended Quick Nav Buttons + .option(Option.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 static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .build()) + //Button 13 + .group(OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button", 13)) + .collapsed(true) + .option(Option.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.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.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.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.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.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.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.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.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.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.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.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 ba863e33c7..173d2532ff 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 @@ 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 a6adf66bb9..2c9d83050a 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 static List init(String screenTitle) { 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 7db785905b..516aed3206 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 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 QuickNavButton(int index, boolean toggled, String command, ItemStack icon 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 void onClick(double mouseX, double mouseY) { * 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 void renderWidget(DrawContext context, int mouseX, int mouseY, float delt // 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(); } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 7da15eccfc..b73c75947b 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -481,6 +481,7 @@ "skyblocker.config.quickNav.button.render": "Render", "skyblocker.config.quickNav.button.uiTitle": "UI Title", "skyblocker.config.quickNav.enableQuickNav": "Enable Quick Navigation", + "skyblocker.config.quickNav.enableExtendedQuickNav": "Enable Extended Quick Navigation", "skyblocker.config.slayer": "Slayers", From 964799fae2c0a6bcffdebc074a72a112e42039b9 Mon Sep 17 00:00:00 2001 From: VeritasDL <121319869+VeritasDL@users.noreply.github.com> Date: Tue, 14 May 2024 20:10:13 -0400 Subject: [PATCH 02/10] Adjusted Button Rendering with the help of BigloBot --- .../skyblock/quicknav/QuickNavButton.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 516aed3206..d964cd3e95 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -46,7 +46,7 @@ private boolean isTopTab() { * @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()); + super(0, 0, 25, 32, Text.empty()); this.index = index; this.toggled = toggled; this.command = command; @@ -64,7 +64,7 @@ private void updateCoordinates() { 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.setX(x + 3 + this.index % 7 * 24); this.setY(this.index < 7 ? y - 25 : y + h - 4); } } @@ -116,14 +116,14 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt } int height = this.height - ((this.toggled) ? 0 : 4); - context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height); + context.drawGuiTexture(BUTTON_TEXTURES, this.getX() + 1, 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; + if (this.index < 7) y -= 3; } else { y += (this.index >= 7) ? 4 : -2; } @@ -136,9 +136,9 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt RenderSystem.enableDepthTest(); } - @Override - protected void appendClickableNarrations(NarrationMessageBuilder builder) { - // TODO Auto-generated method stub + @Override + protected void appendClickableNarrations(NarrationMessageBuilder builder) { + // TODO Auto-generated method stub - } + } } From 0b0d8be21af814c47bf42ce70ca9902092024212 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Wed, 15 May 2024 12:36:30 -0400 Subject: [PATCH 03/10] Clean up rendering code and remove extra buttons option --- .../categories/QuickNavigationCategory.java | 9 --- .../config/configs/QuickNavigationConfig.java | 2 - .../skyblock/quicknav/QuickNav.java | 16 ++--- .../skyblock/quicknav/QuickNavButton.java | 63 ++++--------------- .../assets/skyblocker/lang/en_us.json | 2 +- 5 files changed, 19 insertions(+), 73 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 e6543daff7..40541beaa5 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java @@ -25,15 +25,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) - //Enable Extended Quick Nav Buttons - .option(Option.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)) 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 173d2532ff..e4ecfc5461 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java @@ -5,8 +5,6 @@ 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"); 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 2c9d83050a..cfa7b41bab 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -4,6 +4,7 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.QuickNavigationConfig; +import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.datafixer.ItemStackComponentizationFixer; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; @@ -51,10 +52,8 @@ public static List init(String screenTitle) { 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)); - } + 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); } @@ -69,15 +68,12 @@ private static QuickNavButton parseButton(QuickNavigationConfig.QuickNavItem but try { uiTitleMatches = screenTitle.matches(buttonInfo.uiTitle); } catch (PatternSyntaxException e) { - LOGGER.error("[Skyblocker] Failed to parse Quick Nav Button", e); + LOGGER.error("[Skyblocker] Failed to parse Quick Nav Button with regex: {}", buttonInfo.uiTitle, e); ClientPlayerEntity player = MinecraftClient.getInstance().player; if (player != null) { - player.sendMessage(Text.of(Formatting.RED + "[Skyblocker] Invalid regex in quicknav button " + (id + 1) + "!"), false); + player.sendMessage(Constants.PREFIX.get().append(Text.literal("Invalid regex in Quick Nav Button " + (id + 1) + "!").formatted(Formatting.RED)), false); } } - return new QuickNavButton(id, - uiTitleMatches, - buttonInfo.clickEvent, - stack); + return new QuickNavButton(id, uiTitleMatches, buttonInfo.clickEvent, stack); } } 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 d964cd3e95..e2c5cb0046 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -1,10 +1,8 @@ package de.hysky.skyblocker.skyblock.quicknav; 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; @@ -17,7 +15,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -@Environment(value=EnvType.CLIENT) +@Environment(value = EnvType.CLIENT) public class QuickNavButton extends ClickableWidget { private final int index; private boolean toggled; @@ -27,14 +25,10 @@ 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. + * @return true if the index is less than 7, false otherwise. */ private boolean isTopTab() { - if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { - return index < 6; - } else { - return index < 7; - } + return index < 7; } /** @@ -46,7 +40,7 @@ private boolean isTopTab() { * @param icon the icon to display on the button. */ public QuickNavButton(int index, boolean toggled, String command, ItemStack icon) { - super(0, 0, 25, 32, Text.empty()); + super(0, 0, 26, 32, Text.empty()); this.index = index; this.toggled = toggled; this.command = command; @@ -59,14 +53,8 @@ private void updateCoordinates() { 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 - 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 + 3 + this.index % 7 * 24); - this.setY(this.index < 7 ? y - 25 : y + h - 4); - } + this.setX(x + 27 * this.index % 7); + this.setY(y + this.index < 7 ? -28 : h - 4); } } @@ -102,43 +90,16 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt RenderSystem.disableDepthTest(); // Construct the texture identifier based on the index and toggled state - String tabType = isTopTab() ? "top" : "bottom"; - Identifier BUTTON_TEXTURES = new Identifier("container/creative_inventory/tab_" + tabType + - (toggled ? "_selected_" : "_unselected_") + 2); + Identifier tabTexture = new Identifier("container/creative_inventory/tab_" + (isTopTab() ? "top" : "bottom") + "_" + (toggled ? "selected" : "unselected") + "_" + index % 7); // Render the button texture - int y = this.getY(); - 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() + 1, 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 -= 3; - } 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); - } + context.drawGuiTexture(tabTexture, this.getX(), this.getY(), this.width, this.height); + // Render the button icon + int yOffset = this.index < 7 ? 1 : -1; + context.drawItem(this.icon, this.getX() + 5, this.getY() + 8 + yOffset); RenderSystem.enableDepthTest(); } @Override - protected void appendClickableNarrations(NarrationMessageBuilder builder) { - // TODO Auto-generated method stub - - } + protected void appendClickableNarrations(NarrationMessageBuilder builder) {} } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index b73c75947b..a945dfcd0c 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -473,7 +473,7 @@ "skyblocker.config.quickNav": "Quick Navigation", "skyblocker.config.quickNav.button": "Button %d", - "skyblocker.config.quickNav.button.clickEvent": "Click event", + "skyblocker.config.quickNav.button.clickEvent": "Click Event", "skyblocker.config.quickNav.button.item.components": "Item Components", "skyblocker.config.quickNav.button.item.components.@Tooltip": "A string of item components enclosed in square brackets, which is the same format as the /give command.\n\nExample: [minecraft:enchantment_glint_override=true]", "skyblocker.config.quickNav.button.item.count": "Item Count", From fb4efbbabde2808d9c565e8f638791616c5eb473 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Wed, 15 May 2024 12:46:17 -0400 Subject: [PATCH 04/10] Refactor config --- .../categories/QuickNavigationCategory.java | 738 ++---------------- 1 file changed, 59 insertions(+), 679 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 40541beaa5..acf5b94eea 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java @@ -2,6 +2,7 @@ import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; +import de.hysky.skyblocker.config.configs.QuickNavigationConfig; import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.Option; import dev.isxander.yacl3.api.OptionDescription; @@ -11,7 +12,6 @@ import net.minecraft.text.Text; public class QuickNavigationCategory { - public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) { return ConfigCategory.createBuilder() .name(Text.translatable("skyblocker.config.quickNav")) @@ -25,690 +25,70 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) - //Button 1 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 1)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button1.render, - () -> config.quickNav.button1.render, - newValue -> config.quickNav.button1.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button1.item.id, - () -> config.quickNav.button1.item.id, - newValue -> config.quickNav.button1.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button1.item.count, - () -> config.quickNav.button1.item.count, - newValue -> config.quickNav.button1.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button1.item.components, - () -> config.quickNav.button1.item.components, - newValue -> config.quickNav.button1.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button1.uiTitle, - () -> config.quickNav.button1.uiTitle, - newValue -> config.quickNav.button1.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button1.clickEvent, - () -> config.quickNav.button1.clickEvent, - newValue -> config.quickNav.button1.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 2 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 2)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button2.render, - () -> config.quickNav.button2.render, - newValue -> config.quickNav.button2.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button2.item.id, - () -> config.quickNav.button2.item.id, - newValue -> config.quickNav.button2.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button2.item.count, - () -> config.quickNav.button2.item.count, - newValue -> config.quickNav.button2.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button2.item.components, - () -> config.quickNav.button2.item.components, - newValue -> config.quickNav.button2.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button2.uiTitle, - () -> config.quickNav.button2.uiTitle, - newValue -> config.quickNav.button2.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button2.clickEvent, - () -> config.quickNav.button2.clickEvent, - newValue -> config.quickNav.button2.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 3 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 3)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button3.render, - () -> config.quickNav.button3.render, - newValue -> config.quickNav.button3.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button3.item.id, - () -> config.quickNav.button3.item.id, - newValue -> config.quickNav.button3.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button3.item.count, - () -> config.quickNav.button3.item.count, - newValue -> config.quickNav.button3.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button3.item.components, - () -> config.quickNav.button3.item.components, - newValue -> config.quickNav.button3.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button3.uiTitle, - () -> config.quickNav.button3.uiTitle, - newValue -> config.quickNav.button3.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button3.clickEvent, - () -> config.quickNav.button3.clickEvent, - newValue -> config.quickNav.button3.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 4 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 4)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button4.render, - () -> config.quickNav.button4.render, - newValue -> config.quickNav.button4.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button4.item.id, - () -> config.quickNav.button4.item.id, - newValue -> config.quickNav.button4.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button4.item.count, - () -> config.quickNav.button4.item.count, - newValue -> config.quickNav.button4.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button4.item.components, - () -> config.quickNav.button4.item.components, - newValue -> config.quickNav.button4.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button4.uiTitle, - () -> config.quickNav.button4.uiTitle, - newValue -> config.quickNav.button4.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button4.clickEvent, - () -> config.quickNav.button4.clickEvent, - newValue -> config.quickNav.button4.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 5 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 5)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button5.render, - () -> config.quickNav.button5.render, - newValue -> config.quickNav.button5.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button5.item.id, - () -> config.quickNav.button5.item.id, - newValue -> config.quickNav.button5.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button5.item.count, - () -> config.quickNav.button5.item.count, - newValue -> config.quickNav.button5.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button5.item.components, - () -> config.quickNav.button5.item.components, - newValue -> config.quickNav.button5.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button5.uiTitle, - () -> config.quickNav.button5.uiTitle, - newValue -> config.quickNav.button5.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button5.clickEvent, - () -> config.quickNav.button5.clickEvent, - newValue -> config.quickNav.button5.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 6 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 6)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button6.render, - () -> config.quickNav.button6.render, - newValue -> config.quickNav.button6.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button6.item.id, - () -> config.quickNav.button6.item.id, - newValue -> config.quickNav.button6.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button6.item.count, - () -> config.quickNav.button6.item.count, - newValue -> config.quickNav.button6.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button6.item.components, - () -> config.quickNav.button6.item.components, - newValue -> config.quickNav.button6.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button6.uiTitle, - () -> config.quickNav.button6.uiTitle, - newValue -> config.quickNav.button6.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button6.clickEvent, - () -> config.quickNav.button6.clickEvent, - newValue -> config.quickNav.button6.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 7 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 7)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button7.render, - () -> config.quickNav.button7.render, - newValue -> config.quickNav.button7.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button7.item.id, - () -> config.quickNav.button7.item.id, - newValue -> config.quickNav.button7.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button7.item.count, - () -> config.quickNav.button7.item.count, - newValue -> config.quickNav.button7.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button7.item.components, - () -> config.quickNav.button7.item.components, - newValue -> config.quickNav.button7.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button7.uiTitle, - () -> config.quickNav.button7.uiTitle, - newValue -> config.quickNav.button7.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button7.clickEvent, - () -> config.quickNav.button7.clickEvent, - newValue -> config.quickNav.button7.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) - - //Button 8 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 8)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button8.render, - () -> config.quickNav.button8.render, - newValue -> config.quickNav.button8.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button8.item.id, - () -> config.quickNav.button8.item.id, - newValue -> config.quickNav.button8.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button8.item.count, - () -> config.quickNav.button8.item.count, - newValue -> config.quickNav.button8.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button8.item.components, - () -> config.quickNav.button8.item.components, - newValue -> config.quickNav.button8.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button8.uiTitle, - () -> config.quickNav.button8.uiTitle, - newValue -> config.quickNav.button8.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button8.clickEvent, - () -> config.quickNav.button8.clickEvent, - newValue -> config.quickNav.button8.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) - .build()) + //Buttons + .group(quickNavButton(defaults.quickNav.button1, config.quickNav.button1, 1)) + .group(quickNavButton(defaults.quickNav.button2, config.quickNav.button2, 2)) + .group(quickNavButton(defaults.quickNav.button3, config.quickNav.button3, 3)) + .group(quickNavButton(defaults.quickNav.button4, config.quickNav.button4, 4)) + .group(quickNavButton(defaults.quickNav.button5, config.quickNav.button5, 5)) + .group(quickNavButton(defaults.quickNav.button6, config.quickNav.button6, 6)) + .group(quickNavButton(defaults.quickNav.button7, config.quickNav.button7, 7)) + .group(quickNavButton(defaults.quickNav.button8, config.quickNav.button8, 8)) + .group(quickNavButton(defaults.quickNav.button9, config.quickNav.button9, 9)) + .group(quickNavButton(defaults.quickNav.button10, config.quickNav.button10, 10)) + .group(quickNavButton(defaults.quickNav.button11, config.quickNav.button11, 11)) + .group(quickNavButton(defaults.quickNav.button12, config.quickNav.button12, 12)) + .group(quickNavButton(defaults.quickNav.button13, config.quickNav.button13, 13)) + .group(quickNavButton(defaults.quickNav.button14, config.quickNav.button14, 14)) + .build(); + } - //Button 9 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 9)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button9.render, - () -> config.quickNav.button9.render, - newValue -> config.quickNav.button9.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button9.item.id, - () -> config.quickNav.button9.item.id, - newValue -> config.quickNav.button9.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button9.item.count, - () -> config.quickNav.button9.item.count, - newValue -> config.quickNav.button9.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button9.item.components, - () -> config.quickNav.button9.item.components, - newValue -> config.quickNav.button9.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button9.uiTitle, - () -> config.quickNav.button9.uiTitle, - newValue -> config.quickNav.button9.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button9.clickEvent, - () -> config.quickNav.button9.clickEvent, - newValue -> config.quickNav.button9.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) + private static OptionGroup quickNavButton(QuickNavigationConfig.QuickNavItem defaultButton, QuickNavigationConfig.QuickNavItem button, int index) { + return OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button", index)) + .collapsed(true) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.render")) + .binding(defaultButton.render, + () -> button.render, + newValue -> button.render = newValue) + .controller(ConfigUtils::createBooleanController) .build()) - - //Button 10 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 10)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button10.render, - () -> config.quickNav.button10.render, - newValue -> config.quickNav.button10.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button10.item.id, - () -> config.quickNav.button10.item.id, - newValue -> config.quickNav.button10.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button10.item.count, - () -> config.quickNav.button10.item.count, - newValue -> config.quickNav.button10.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button10.item.components, - () -> config.quickNav.button10.item.components, - newValue -> config.quickNav.button10.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button10.uiTitle, - () -> config.quickNav.button10.uiTitle, - newValue -> config.quickNav.button10.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button10.clickEvent, - () -> config.quickNav.button10.clickEvent, - newValue -> config.quickNav.button10.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) + .binding(defaultButton.item.id, + () -> button.item.id, + newValue -> button.item.id = newValue) + .controller(StringControllerBuilder::create) .build()) - - //Button 11 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 11)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button11.render, - () -> config.quickNav.button11.render, - newValue -> config.quickNav.button11.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button11.item.id, - () -> config.quickNav.button11.item.id, - newValue -> config.quickNav.button11.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button11.item.count, - () -> config.quickNav.button11.item.count, - newValue -> config.quickNav.button11.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button11.item.components, - () -> config.quickNav.button11.item.components, - newValue -> config.quickNav.button11.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button11.uiTitle, - () -> config.quickNav.button11.uiTitle, - newValue -> config.quickNav.button11.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button11.clickEvent, - () -> config.quickNav.button11.clickEvent, - newValue -> config.quickNav.button11.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) + .binding(defaultButton.item.count, + () -> button.item.count, + newValue -> button.item.count = newValue) + .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) .build()) - - //Button 12 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 12)) - .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.render")) - .binding(defaults.quickNav.button12.render, - () -> config.quickNav.button12.render, - newValue -> config.quickNav.button12.render = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaults.quickNav.button12.item.id, - () -> config.quickNav.button12.item.id, - newValue -> config.quickNav.button12.item.id = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaults.quickNav.button12.item.count, - () -> config.quickNav.button12.item.count, - newValue -> config.quickNav.button12.item.count = newValue) - .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) - .build()) - .option(Option.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.button12.item.components, - () -> config.quickNav.button12.item.components, - newValue -> config.quickNav.button12.item.components = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) - .binding(defaults.quickNav.button12.uiTitle, - () -> config.quickNav.button12.uiTitle, - newValue -> config.quickNav.button12.uiTitle = newValue) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) - .binding(defaults.quickNav.button12.clickEvent, - () -> config.quickNav.button12.clickEvent, - newValue -> config.quickNav.button12.clickEvent = newValue) - .controller(StringControllerBuilder::create) - .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.item.components")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.quickNav.button.item.components.@Tooltip"))) + .binding(defaultButton.item.components, + () -> button.item.components, + newValue -> button.item.components = newValue) + .controller(StringControllerBuilder::create) .build()) - - //Button 13 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 13)) - .collapsed(true) - .option(Option.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.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.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.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.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.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()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.uiTitle")) + .binding(defaultButton.uiTitle, + () -> button.uiTitle, + newValue -> button.uiTitle = newValue) + .controller(StringControllerBuilder::create) .build()) - - //Button 14 - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.quickNav.button", 14)) - .collapsed(true) - .option(Option.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.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.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.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.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.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()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.quickNav.button.clickEvent")) + .binding(defaultButton.clickEvent, + () -> button.clickEvent, + newValue -> button.clickEvent = newValue) + .controller(StringControllerBuilder::create) .build()) .build(); } From c43c27493a0c3110bcdb6479da80c3641133ccee Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Wed, 15 May 2024 16:34:24 -0400 Subject: [PATCH 05/10] Add Quick Nav data fixer and refactor tabs --- .../de/hysky/skyblocker/SkyblockerMod.java | 2 +- .../config/SkyblockerConfigManager.java | 2 +- .../categories/QuickNavigationCategory.java | 24 +- .../config/configs/QuickNavigationConfig.java | 70 +-- .../config/datafixer/ConfigDataFix.java | 16 + .../config/datafixer/ConfigDataFixer.java | 8 +- .../config/datafixer/ConfigFix1.java | 6 +- .../config/datafixer/ConfigFix2QuickNav.java | 38 ++ .../java/de/hysky/skyblocker/debug/Debug.java | 27 +- .../skyblocker/mixins/HandledScreenMixin.java | 44 +- .../accessors/HandledScreenAccessor.java | 4 + .../skyblock/quicknav/QuickNav.java | 14 +- .../skyblock/quicknav/QuickNavButton.java | 10 +- .../de/hysky/skyblocker/utils/ItemUtils.java | 4 +- .../config/datafixer/ConfigDataFixerTest.java | 10 + .../skyblocker/config/skyblocker-v3.json | 573 ++++++++++++++++++ 16 files changed, 771 insertions(+), 81 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFix.java create mode 100644 src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix2QuickNav.java create mode 100644 src/test/resources/assets/skyblocker/config/skyblocker-v3.json diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 77b1ec2a9c..0dc1b409fc 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -76,6 +76,7 @@ public class SkyblockerMod implements ClientModInitializer { public static final String VERSION = SKYBLOCKER_MOD.getMetadata().getVersion().getFriendlyString(); public static final Path CONFIG_DIR = FabricLoader.getInstance().getConfigDir().resolve(NAMESPACE); public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + public static final Gson GSON_COMPACT = new GsonBuilder().create(); private static SkyblockerMod INSTANCE; public final ContainerSolverManager containerSolverManager = new ContainerSolverManager(); public final StatusBarTracker statusBarTracker = new StatusBarTracker(); @@ -119,7 +120,6 @@ public void onInitializeClient() { EnderNodes.init(); OrderedWaypoints.init(); BackpackPreview.init(); - QuickNav.init(); ItemCooldowns.init(); TabHud.init(); DwarvenHud.init(); diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java index 688b85aa11..b7728030b6 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java @@ -26,7 +26,7 @@ import java.nio.file.Path; public class SkyblockerConfigManager { - public static final int CONFIG_VERSION = 2; + public static final int CONFIG_VERSION = 3; private static final Path CONFIG_FILE = FabricLoader.getInstance().getConfigDir().resolve("skyblocker.json"); private static final ConfigClassHandler HANDLER = ConfigClassHandler.createBuilder(SkyblockerConfig.class) .serializer(config -> GsonConfigSerializerBuilder.create(config) 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 acf5b94eea..98e5511c4b 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java @@ -8,7 +8,9 @@ import dev.isxander.yacl3.api.OptionDescription; import dev.isxander.yacl3.api.OptionGroup; import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder; +import dev.isxander.yacl3.api.controller.ItemControllerBuilder; import dev.isxander.yacl3.api.controller.StringControllerBuilder; +import net.minecraft.item.Item; import net.minecraft.text.Text; public class QuickNavigationCategory { @@ -54,26 +56,26 @@ private static OptionGroup quickNavButton(QuickNavigationConfig.QuickNavItem def newValue -> button.render = newValue) .controller(ConfigUtils::createBooleanController) .build()) - .option(Option.createBuilder() + .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.quickNav.button.item.itemName")) - .binding(defaultButton.item.id, - () -> button.item.id, - newValue -> button.item.id = newValue) - .controller(StringControllerBuilder::create) + .binding(defaultButton.itemData.item, + () -> button.itemData.item, + newValue -> button.itemData.item = newValue) + .controller(ItemControllerBuilder::create) .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.quickNav.button.item.count")) - .binding(defaultButton.item.count, - () -> button.item.count, - newValue -> button.item.count = newValue) + .binding(defaultButton.itemData.count, + () -> button.itemData.count, + newValue -> button.itemData.count = newValue) .controller(opt -> IntegerFieldControllerBuilder.create(opt).range(1, 99)) .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.quickNav.button.item.components")) .description(OptionDescription.of(Text.translatable("skyblocker.config.quickNav.button.item.components.@Tooltip"))) - .binding(defaultButton.item.components, - () -> button.item.components, - newValue -> button.item.components = newValue) + .binding(defaultButton.itemData.components, + () -> button.itemData.components, + newValue -> button.itemData.components = newValue) .controller(StringControllerBuilder::create) .build()) .option(Option.createBuilder() 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 e4ecfc5461..548354c7e8 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java @@ -1,6 +1,9 @@ package de.hysky.skyblocker.config.configs; import dev.isxander.yacl3.config.v2.api.SerialEntry; +import net.minecraft.item.Item; +import net.minecraft.registry.Registries; +import net.minecraft.util.Identifier; public class QuickNavigationConfig { @SerialEntry @@ -24,14 +27,13 @@ public class QuickNavigationConfig { * " \\([12]\\/2\\)" : match on the page either " (1/2)" or " (2/2)" */ @SerialEntry - public QuickNavItem button4 = new QuickNavItem(true, - new ItemData("leather_chestplate", 1, "[minecraft:dyed_color={rgb:8991416}]"), "Wardrobe \\([12]/2\\)", - "/wardrobe"); + public QuickNavItem button4 = new QuickNavItem(true, new ItemData("leather_chestplate", 1, "[minecraft:dyed_color={rgb:8991416}]"), "Wardrobe \\([12]/2\\)", "/wardrobe"); @SerialEntry - public QuickNavItem button5 = new QuickNavItem(true, new ItemData("player_head", 1, - "[minecraft:profile={id:[I;-2081424676,-57521078,-2073572414,158072763],name:\"\",properties:[{name:\"textures\",value:\"ewogICJ0aW1lc3RhbXAiIDogMTU5MTMxMDU4NTYwOSwKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBhMDc3ZTI0OGQxNDI3NzJlYTgwMDg2NGY4YzU3OGI5ZDM2ODg1YjI5ZGFmODM2YjY0YTcwNjg4MmI2ZWMxMCIKICAgIH0KICB9Cn0=\"}]}]"), - "Sack of Sacks", "/sacks"); + public QuickNavItem button5 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;-2081424676,-57521078,-2073572414,158072763],name:\"\",properties:[{name:\"textures\",value:\"ewogICJ0aW1lc3RhbXAiIDogMTU5MTMxMDU4NTYwOSwKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBhMDc3ZTI0OGQxNDI3NzJlYTgwMDg2NGY4YzU3OGI5ZDM2ODg1YjI5ZGFmODM2YjY0YTcwNjg4MmI2ZWMxMCIKICAgIH0KICB9Cn0=\"}]}]"), "Sack of Sacks", "/sacks"); + + @SerialEntry + public QuickNavItem button6 = new QuickNavItem(true, new ItemData("player_head", 1, "[\"minecraft:profile\":{\"name\":\"5da6bec64bd942bc\",\"id\":[1571208902,1272529596,-1566400349,-679283814],\"properties\":[{\"name\":\"textures\",\"value\":\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTYxYTkxOGMwYzQ5YmE4ZDA1M2U1MjJjYjkxYWJjNzQ2ODkzNjdiNGQ4YWEwNmJmYzFiYTkxNTQ3MzA5ODVmZiJ9fX0\\u003d\"}]}]"), "Accessory Bag(?: \\(\\d/\\d\\))?", "/accessories"); /* REGEX Explanation * "(?:Rift )?" : optional match on the non-capturing group "Rift " @@ -39,54 +41,42 @@ public class QuickNavigationConfig { * "(?: \\([12]\\/2\\))?" : optional match on the non-capturing group " (1/2)" or " (2/2)" */ @SerialEntry - public QuickNavItem button6 = new QuickNavItem(true, new ItemData("ender_chest"), - "(?:Rift )?Storage(?: \\(1/2\\))?", "/storage"); + public QuickNavItem button7 = new QuickNavItem(true, new ItemData("ender_chest"), "(?:Rift )?Storage(?: \\(\\d/\\d\\))?", "/storage"); @SerialEntry - public QuickNavItem button7 = new QuickNavItem(true, new ItemData("player_head", 1, - "[minecraft:profile={id:[I;-300151517,-631415889,-1193921967,-1821784279],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0=\"}]}]"), - "none", "/hub"); + public QuickNavItem button8 = new QuickNavItem(true, new ItemData("player_head", 1, "[\"minecraft:profile\":{\"name\":\"421a8ef40eff47f4\",\"id\":[1109036788,251611124,-2126904485,-130621758],\"properties\":[{\"name\":\"textures\",\"value\":\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0\\u003d\"}]}]"), "", "/is"); @SerialEntry - public QuickNavItem button8 = new QuickNavItem(true, new ItemData("player_head", 1, - "[minecraft:profile={id:[I;1605800870,415127827,-1236127084,15358548],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MWQ1YjI3M2ZmMGJjNTBjOTYwYjJjZDg2ZWVmMWM0MGExYjk0MDMyYWU3MWU3NTQ3NWE1NjhhODI1NzQyMSJ9fX0=\"}]}]"), - "none", "/warp dungeon_hub"); + public QuickNavItem button9 = new QuickNavItem(true, new ItemData("player_head", 1, "[\"minecraft:profile\":{\"name\":\"e30e30d02878417c\",\"id\":[-485609264,678969724,-1929747597,-718202427],\"properties\":[{\"name\":\"textures\",\"value\":\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjQ4ODBkMmMxZTdiODZlODc1MjJlMjA4ODI2NTZmNDViYWZkNDJmOTQ5MzJiMmM1ZTBkNmVjYWE0OTBjYjRjIn19fQ\\u003d\\u003d\"}]}]"), "", "/warp garden"); @SerialEntry - public QuickNavItem button9 = new QuickNavItem(true, new ItemData("player_head", 1, - "[minecraft:profile={id:[I;-562285948,532499670,-1705302742,775653035],name:\"\",properties:[{name:\"textures\",value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjVkZjU1NTkyNjQzMGQ1ZDc1YWRlZDIxZGQ5NjE5Yjc2YzViN2NhMmM3ZjU0MDE0NDA1MjNkNTNhOGJjZmFhYiJ9fX0=\"}]}]"), - "Visit prtl", "/visit prtl"); + public QuickNavItem button10 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;-300151517,-631415889,-1193921967,-1821784279],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0=\"}]}]"), "none", "/hub"); @SerialEntry - public QuickNavItem button10 = new QuickNavItem(true, new ItemData("enchanting_table"), "Enchant Item", - "/etable"); - + public QuickNavItem button11 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;1605800870,415127827,-1236127084,15358548],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MWQ1YjI3M2ZmMGJjNTBjOTYwYjJjZDg2ZWVmMWM0MGExYjk0MDMyYWU3MWU3NTQ3NWE1NjhhODI1NzQyMSJ9fX0=\"}]}]"), "none", "/warp dungeon_hub"); @SerialEntry - public QuickNavItem button11 = new QuickNavItem(true, new ItemData("anvil"), "Anvil", "/anvil"); - - @SerialEntry - public QuickNavItem button12 = new QuickNavItem(true, new ItemData("crafting_table"), "Craft Item", "/craft"); + public QuickNavItem button12 = new QuickNavItem(true, new ItemData("gold_block"), "", "/ah"); @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 QuickNavItem button14 = new QuickNavItem(true, new ItemData("crafting_table"), "Craft Item", "/craft"); public static class QuickNavItem { public QuickNavItem(Boolean render, ItemData itemData, String uiTitle, String clickEvent) { this.render = render; - this.item = itemData; + this.itemData = itemData; this.clickEvent = clickEvent; this.uiTitle = uiTitle; } @SerialEntry - public Boolean render; + public boolean render; @SerialEntry - public ItemData item; + public ItemData itemData; @SerialEntry public String uiTitle; @@ -96,20 +86,26 @@ public QuickNavItem(Boolean render, ItemData itemData, String uiTitle, String cl } public static class ItemData { - public ItemData(String id, int count, String components) { - this.id = id; - this.count = count; - this.components = components; + public ItemData(String item) { + this(item, 1, "[]"); } - public ItemData(String id) { - this.id = id; - this.count = 1; - this.components = "[]"; + public ItemData(String item, int count, String components) { + this(Registries.ITEM.get(new Identifier(item)), count, components); + } + + public ItemData(Item item) { + this(item, 1, "[]"); + } + + public ItemData(Item item, int count, String components) { + this.item = item; + this.count = count; + this.components = components; } @SerialEntry - public String id; + public Item item; @SerialEntry public int count; diff --git a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFix.java b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFix.java new file mode 100644 index 0000000000..9ec0e2b81c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFix.java @@ -0,0 +1,16 @@ +package de.hysky.skyblocker.config.datafixer; + +import com.mojang.datafixers.DataFix; +import com.mojang.datafixers.DataFixUtils; +import com.mojang.datafixers.schemas.Schema; +import com.mojang.serialization.Dynamic; + +public abstract class ConfigDataFix extends DataFix { + public ConfigDataFix(Schema outputSchema, boolean changesType) { + super(outputSchema, changesType); + } + + protected Dynamic fixVersion(Dynamic dynamic) { + return dynamic.set("version", dynamic.createInt(DataFixUtils.getVersion(getVersionKey()))); + } +} diff --git a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixer.java b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixer.java index 97261c76a5..f4e4aad1f7 100644 --- a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixer.java +++ b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixer.java @@ -47,9 +47,13 @@ public static void apply(Path configDir, Path backupDir) { } public static JsonObject apply(JsonObject oldConfig) { + return apply(oldConfig, SkyblockerConfigManager.CONFIG_VERSION); + } + + public static JsonObject apply(JsonObject oldConfig, int newVersion) { long start = System.currentTimeMillis(); - JsonObject newConfig = build().update(CONFIG_TYPE, new Dynamic<>(JsonOps.INSTANCE, oldConfig), JsonHelper.getInt(oldConfig, "version").orElse(1), SkyblockerConfigManager.CONFIG_VERSION).getValue().getAsJsonObject(); + JsonObject newConfig = build().update(CONFIG_TYPE, new Dynamic<>(JsonOps.INSTANCE, oldConfig), JsonHelper.getInt(oldConfig, "version").orElse(1), newVersion).getValue().getAsJsonObject(); long end = System.currentTimeMillis(); LOGGER.info("[Skyblocker Config Data Fixer] Applied datafixers in {} ms!", end - start); @@ -62,6 +66,8 @@ private static DataFixer build() { builder.addSchema(1, ConfigSchema::new); Schema schema2 = builder.addSchema(2, Schema::new); builder.addFixer(new ConfigFix1(schema2, true)); + Schema schema3 = builder.addSchema(3, Schema::new); + builder.addFixer(new ConfigFix2QuickNav(schema3, true)); return builder.buildUnoptimized(); } diff --git a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java index 405a278150..e8198d7706 100644 --- a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java +++ b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java @@ -14,7 +14,7 @@ import java.util.Locale; -public class ConfigFix1 extends DataFix { +public class ConfigFix1 extends ConfigDataFix { public ConfigFix1(Schema outputSchema, boolean changesType) { super(outputSchema, changesType); } @@ -32,10 +32,6 @@ private Dynamic fix(Dynamic dynamic) { return fixMisc(fixQuickNav(fixChat(fixSlayers(fixOtherLocations(fixFarming(fixMining(fixCrimsonIsle(fixDungeons(fixHelpers(fixUIAndVisuals(fixGeneral(fixVersion(dynamic))))))))))))); } - private Dynamic fixVersion(Dynamic dynamic) { - return dynamic.set("version", dynamic.createInt(DataFixUtils.getVersion(getVersionKey()))); - } - private static Dynamic fixGeneral(Dynamic dynamic) { return dynamic.update("general", general -> general.update("itemTooltip", itemTooltip -> itemTooltip.setFieldIfPresent("dungeonQuality", general.get("dungeonQuality").result())).remove("dungeonQuality")); } diff --git a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix2QuickNav.java b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix2QuickNav.java new file mode 100644 index 0000000000..bd67b1b076 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix2QuickNav.java @@ -0,0 +1,38 @@ +package de.hysky.skyblocker.config.datafixer; + +import com.mojang.datafixers.DSL; +import com.mojang.datafixers.TypeRewriteRule; +import com.mojang.datafixers.schemas.Schema; +import com.mojang.serialization.Dynamic; +import net.minecraft.util.Identifier; + +public class ConfigFix2QuickNav extends ConfigDataFix { + public ConfigFix2QuickNav(Schema outputSchema, boolean changesType) { + super(outputSchema, changesType); + } + + @Override + protected TypeRewriteRule makeRule() { + return fixTypeEverywhereTyped( + "ConfigFix2QuickNav", + getInputSchema().getType(ConfigDataFixer.CONFIG_TYPE), + typed -> typed.update(DSL.remainderFinder(), this::fix) + ); + } + + private Dynamic fix(Dynamic dynamic) { + return fixVersion(dynamic).update("quickNav", quickNav -> quickNav + .renameField("button12", "button13") + .renameField("button11", "button12") + .renameField("button10", "button11") + .renameField("button9", "button10") + .renameField("button8", "button9") + .renameField("button7", "button8") + .updateMapValues(button -> button.getFirst().asString().getOrThrow().startsWith("button") ? button.mapSecond(this::fixButton) : button) + ); + } + + private Dynamic fixButton(Dynamic button) { + return button.renameAndFixField("item", "itemData", itemData -> itemData.renameAndFixField("id", "item", id -> id.createString(new Identifier(id.asString().getOrThrow()).toString()))); + } +} diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 8c883b30e9..d9ac668c31 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -2,21 +2,27 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.ItemUtils; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; +import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.item.ItemStack; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.text.Text; - -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; +import org.lwjgl.glfw.GLFW; import java.util.List; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + public class Debug { private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); @@ -26,6 +32,10 @@ public static boolean debugEnabled() { return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment(); } + public static boolean shouldShowInvisibleArmorStands() { + return showInvisibleArmorStands; + } + public static void init() { if (debugEnabled()) { SnapshotDebug.init(); @@ -35,6 +45,15 @@ public static void init() { .then(toggleShowingInvisibleArmorStands()) .then(dumpArmorStandHeadTextures()) ))); + ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> { + if (screen instanceof HandledScreen handledScreen) { + ScreenKeyboardEvents.afterKeyPress(screen).register((_screen, key, scancode, modifier) -> { + if (key == GLFW.GLFW_KEY_U && client.player != null) { + client.player.sendMessage(Text.literal("[Skyblocker Debug] Hovered Item: " + SkyblockerMod.GSON_COMPACT.toJson(ItemStack.CODEC.encodeStart(JsonOps.INSTANCE, ((HandledScreenAccessor) handledScreen).getFocusedSlot().getStack())))); + } + }); + } + }); } } @@ -73,8 +92,4 @@ private static LiteralArgumentBuilder dumpArmorStandH return Command.SINGLE_SUCCESS; }); } - - public static boolean shouldShowInvisibleArmorStands() { - return showInvisibleArmorStands; - } } diff --git a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java index dd91314a3e..f662be7c78 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java @@ -14,6 +14,8 @@ import de.hysky.skyblocker.skyblock.item.WikiLookup; import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; import de.hysky.skyblocker.skyblock.item.tooltip.CompactorDeletorPreview; +import de.hysky.skyblocker.skyblock.quicknav.QuickNav; +import de.hysky.skyblocker.skyblock.quicknav.QuickNavButton; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.gui.ContainerSolver; @@ -41,6 +43,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; @@ -89,10 +92,22 @@ public abstract class HandledScreenMixin extends Screen @Final protected T handler; + @Unique + private List quickNavButtons; + protected HandledScreenMixin(Text title) { super(title); } + @Inject(method = "init", at = @At("RETURN")) + private void skyblocker$initQuickNav(CallbackInfo ci) { + if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().quickNav.enableQuickNav && client != null && client.player != null && !client.player.isCreative()) { + for (QuickNavButton quickNavButton : quickNavButtons = QuickNav.init(getTitle().getString().trim())) { + addSelectableChild(quickNavButton); + } + } + } + @Inject(at = @At("HEAD"), method = "keyPressed") public void skyblocker$keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { if (this.client != null && this.focusedSlot != null && keyCode != 256) { @@ -109,8 +124,33 @@ protected HandledScreenMixin(Text title) { @Inject(at = @At("HEAD"), method = "mouseClicked") public void skyblocker$mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { - if (SkyblockerConfigManager.get().farming.garden.visitorHelper && (Utils.getLocationRaw().equals("garden") && !getTitle().getString().contains("Logbook") || getTitle().getString().startsWith("Bazaar"))) + if (SkyblockerConfigManager.get().farming.garden.visitorHelper && (Utils.getLocationRaw().equals("garden") && !getTitle().getString().contains("Logbook") || getTitle().getString().startsWith("Bazaar"))) { VisitorHelper.onMouseClicked(mouseX, mouseY, button, this.textRenderer); + } + } + + /** + * Draws the unselected tabs in front of the background blur, but behind the main inventory, similar to creative inventory tabs + */ + @Inject(method = "renderBackground", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/gui/DrawContext;FII)V")) + private void skyblocker$drawUnselectedQuickNavButtons(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { + if (quickNavButtons != null) for (QuickNavButton quickNavButton : quickNavButtons) { + if (!quickNavButton.toggled()) { + quickNavButton.render(context, mouseX, mouseY, delta); + } + } + } + + /** + * Draws the selected tab in front of the background blur and the main inventory, similar to creative inventory tabs + */ + @Inject(method = "renderBackground", at = @At("RETURN")) + private void skyblocker$drawSelectedQuickNavButtons(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { + if (quickNavButtons != null) for (QuickNavButton quickNavButton : quickNavButtons) { + if (quickNavButton.toggled()) { + quickNavButton.render(context, mouseX, mouseY, delta); + } + } } @SuppressWarnings("DataFlowIssue") @@ -165,7 +205,7 @@ protected HandledScreenMixin(Text title) { /** * The naming of this method in yarn is half true, its mostly to handle slot/item interactions (which are mouse or keyboard clicks) * For example, using the drop key bind while hovering over an item will invoke this method to drop the players item - * + * * @implNote This runs before {@link ScreenHandler#onSlotClick(int, int, SlotActionType, net.minecraft.entity.player.PlayerEntity)} */ @Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;clickSlot(IIILnet/minecraft/screen/slot/SlotActionType;Lnet/minecraft/entity/player/PlayerEntity;)V"), cancellable = true) diff --git a/src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java index 447031d471..9a2a8311c2 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java @@ -2,6 +2,7 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.slot.Slot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @@ -23,4 +24,7 @@ public interface HandledScreenAccessor { @Mutable @Accessor("handler") void setHandler(ScreenHandler handler); + + @Accessor("focusedSlot") + Slot getFocusedSlot(); } 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 cfa7b41bab..8a66996fcf 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -26,16 +26,6 @@ public class QuickNav { private static final Logger LOGGER = LoggerFactory.getLogger(QuickNav.class); - public static void init() { - ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> { - if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().quickNav.enableQuickNav && screen instanceof HandledScreen && client.player != null && !client.player.isCreative()) { - String screenTitle = screen.getTitle().getString().trim(); - List buttons = QuickNav.init(screenTitle); - for (QuickNavButton button : buttons) Screens.getButtons(screen).add(button); - } - }); - } - public static List init(String screenTitle) { List buttons = new ArrayList<>(); QuickNavigationConfig data = SkyblockerConfigManager.get().quickNav; @@ -61,8 +51,8 @@ public static List init(String screenTitle) { } private static QuickNavButton parseButton(QuickNavigationConfig.QuickNavItem buttonInfo, String screenTitle, int id) throws CommandSyntaxException { - QuickNavigationConfig.ItemData itemData = buttonInfo.item; - ItemStack stack = ItemStackComponentizationFixer.fromComponentsString(itemData.id, Math.clamp(itemData.count, 1, 99), itemData.components); + QuickNavigationConfig.ItemData itemData = buttonInfo.itemData; + ItemStack stack = ItemStackComponentizationFixer.fromComponentsString(itemData.item.toString(), Math.clamp(itemData.count, 1, 99), itemData.components); boolean uiTitleMatches = false; try { 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 e2c5cb0046..f9ca094093 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -31,6 +31,10 @@ private boolean isTopTab() { return index < 7; } + public boolean toggled() { + return toggled; + } + /** * Constructs a new QuickNavButton with the given parameters. * @@ -53,8 +57,8 @@ private void updateCoordinates() { int x = ((HandledScreenAccessor) handledScreen).getX(); int y = ((HandledScreenAccessor) handledScreen).getY(); int h = ((HandledScreenAccessor) handledScreen).getBackgroundHeight(); - this.setX(x + 27 * this.index % 7); - this.setY(y + this.index < 7 ? -28 : h - 4); + this.setX(x + this.index % 7 * 25); + this.setY(this.index < 7 ? y - 28 : y + h - 4); } } @@ -90,7 +94,7 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt RenderSystem.disableDepthTest(); // Construct the texture identifier based on the index and toggled state - Identifier tabTexture = new Identifier("container/creative_inventory/tab_" + (isTopTab() ? "top" : "bottom") + "_" + (toggled ? "selected" : "unselected") + "_" + index % 7); + Identifier tabTexture = new Identifier("container/creative_inventory/tab_" + (isTopTab() ? "top" : "bottom") + "_" + (toggled ? "selected" : "unselected") + "_" + (index % 7 + 1)); // Render the button texture context.drawGuiTexture(tabTexture, this.getX(), this.getY(), this.width, this.height); diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index 086686a77d..6a2af75108 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -9,6 +9,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; import com.mojang.serialization.codecs.RecordCodecBuilder; +import de.hysky.skyblocker.SkyblockerMod; import it.unimi.dsi.fastutil.ints.IntIntPair; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.component.ComponentChanges; @@ -49,7 +50,6 @@ public class ItemUtils { private static final DateTimeFormatter OLD_OBTAINED_DATE_FORMAT = DateTimeFormatter.ofPattern("M/d/yy h:m a").withZone(ZoneId.of("UTC")).localizedBy(Locale.ENGLISH); public static final Pattern NOT_DURABILITY = Pattern.compile("[^0-9 /]"); public static final Predicate FUEL_PREDICATE = line -> line.contains("Fuel: "); - private static final Gson GSON = new Gson(); //GSON Instance with no config private static final Codec> EMPTY_ALLOWING_ITEM_CODEC = Registries.ITEM.getEntryCodec(); public static final Codec EMPTY_ALLOWING_ITEMSTACK_CODEC = Codec.lazyInitialized(() -> RecordCodecBuilder.create(instance -> instance.group( EMPTY_ALLOWING_ITEM_CODEC.fieldOf("id").forGetter(ItemStack::getRegistryEntry), @@ -59,7 +59,7 @@ public class ItemUtils { public static LiteralArgumentBuilder dumpHeldItemCommand() { return literal("dumpHeldItem").executes(context -> { - context.getSource().sendFeedback(Text.literal("[Skyblocker Debug] Held Item: " + GSON.toJson(ItemStack.CODEC.encodeStart(JsonOps.INSTANCE, context.getSource().getPlayer().getMainHandStack()).getOrThrow()))); + context.getSource().sendFeedback(Text.literal("[Skyblocker Debug] Held Item: " + SkyblockerMod.GSON_COMPACT.toJson(ItemStack.CODEC.encodeStart(JsonOps.INSTANCE, context.getSource().getPlayer().getMainHandStack()).getOrThrow()))); return Command.SINGLE_SUCCESS; }); } diff --git a/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java b/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java index aab10084be..fcdbc31422 100644 --- a/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java +++ b/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java @@ -27,6 +27,16 @@ void testDataFixer1() { @SuppressWarnings("DataFlowIssue") JsonObject expectedNewConfig = GSON.fromJson(new InputStreamReader(ConfigDataFixerTest.class.getResourceAsStream("/assets/skyblocker/config/skyblocker-v2.json")), JsonObject.class); + Assertions.assertEquals(expectedNewConfig, ConfigDataFixer.apply(oldConfig, 2)); + } + + @Test + void testDataFixer2QuickNav() { + @SuppressWarnings("DataFlowIssue") + JsonObject oldConfig = GSON.fromJson(new InputStreamReader(ConfigDataFixerTest.class.getResourceAsStream("/assets/skyblocker/config/skyblocker-v2.json")), JsonObject.class); + @SuppressWarnings("DataFlowIssue") + JsonObject expectedNewConfig = GSON.fromJson(new InputStreamReader(ConfigDataFixerTest.class.getResourceAsStream("/assets/skyblocker/config/skyblocker-v3.json")), JsonObject.class); + Assertions.assertEquals(expectedNewConfig, ConfigDataFixer.apply(oldConfig)); } } diff --git a/src/test/resources/assets/skyblocker/config/skyblocker-v3.json b/src/test/resources/assets/skyblocker/config/skyblocker-v3.json new file mode 100644 index 0000000000..d298fff122 --- /dev/null +++ b/src/test/resources/assets/skyblocker/config/skyblocker-v3.json @@ -0,0 +1,573 @@ +{ + "version": 3, + "general": { + "enableTips": true, + "acceptReparty": true, + "shortcuts": { + "enableShortcuts": true, + "enableCommandShortcuts": true, + "enableCommandArgShortcuts": true + }, + "quiverWarning": { + "enableQuiverWarning": true, + "enableQuiverWarningInDungeons": true, + "enableQuiverWarningAfterDungeon": true + }, + "itemList": { + "enableItemList": true + }, + "itemTooltip": { + "enableNPCPrice": true, + "enableMotesPrice": true, + "enableAvgBIN": true, + "avg": "THREE_DAY", + "enableLowestBIN": true, + "enableBazaarPrice": true, + "enableObtainedDate": true, + "enableMuseumInfo": true, + "enableExoticTooltip": true, + "enableAccessoriesHelper": true, + "dungeonQuality": true + }, + "itemInfoDisplay": { + "attributeShardInfo": true, + "itemRarityBackgrounds": true, + "itemRarityBackgroundStyle": "CIRCULAR", + "itemRarityBackgroundsOpacity": 0.5 + }, + "itemProtection": { + "slotLockStyle": "FANCY" + }, + "wikiLookup": { + "enableWikiLookup": true, + "officialWiki": false + }, + "specialEffects": { + "rareDungeonDropEffects": true + }, + "hitbox": { + "oldFarmlandHitbox": true, + "oldLeverHitbox": false + }, + "lockedSlots": [ + 3, + 8, + 0 + ], + "protectedItems": [ + "10f84455-c063-4e3e-b6eb-cc485fe74a06", + "64e491fa-64ed-4abf-829a-940e1fb295d2", + "23a619b6-f487-419e-8598-10b8f21dc80a", + "416aa42d-27d4-4284-913f-d03fa1f528c3", + "4e2a7f16-7d93-4069-bfbd-a8ff8e42f285", + "63ec4f84-2005-45e5-a4b7-0c9ae84dc612", + "aba2b017-91e8-4263-ae9e-5a10f8dc91fe", + "f1391873-5126-496d-b0fe-c861faeaf681", + "bb84cfea-3fdd-4579-b5fa-907cd8123593", + "a604f533-49f6-4190-b971-08f725231229", + "333cba8d-3136-4494-9fa0-40dff482ef66", + "91f49338-fc0b-4601-a704-aabc44853318", + "d76e5eca-be47-4d0b-973c-3ec30fd176dc", + "301c58a7-9b8a-4c4e-9e8d-3e8a9471a916", + "c8ab629e-fc5b-4af0-8053-acb155411c9b", + "333a079f-93d4-48f1-af9f-862b1ecc417c", + "0843d8b0-b6a6-47fc-afde-8eee8c5455d9", + "8bcf2a99-68e6-4646-ac04-4c72e55c6818", + "214333db-d71c-4080-8487-00b4666bb9a4", + "1eba38b5-e0f6-4862-bf19-e2df33e21ce4", + "6b42c77f-1891-43a4-a9ea-4454e299a059", + "71ce1812-d1fd-4e71-98ad-8b863759a82f", + "253489d9-49d0-46c8-b3f8-b70c3663c5d2", + "6033eff2-879d-494f-8dae-696fc8a3c82e", + "5f6090c8-cbc4-4030-97ac-5018c151cc15", + "64162e02-91fb-4ec3-a57c-866436a99a7a", + "a299c718-c66b-4de5-9747-71c172ac4601", + "e21172ce-0a41-426a-a445-84a28677cd65", + "4bfd23bf-ceb8-4951-874d-e61633e088d8", + "575ce2c9-251e-4435-9020-de1a2e24b1d0", + "b06b8fe2-470a-43f3-b844-658472f20996", + "e54dea3d-ca45-451e-9ae4-0e5fb87e97b2", + "67b47348-da46-4257-833a-dd23fb074cc6", + "9f7597ec-c3c9-46df-9f36-8e76c8745a9d", + "e297dcef-2f3d-4fb3-9781-aaff6017178c", + "ad9a598d-e5c9-4293-92c8-5e41bebe913c", + "fa51c660-b262-4826-bed8-6138236919cb" + ], + "customItemNames": {}, + "customDyeColors": {}, + "customArmorTrims": { + "f1391873-5126-496d-b0fe-c861faeaf681": { + "material": "minecraft:amethyst", + "pattern": "minecraft:raiser" + }, + "81409da1-610c-445a-aba2-4c95a3cabbf2": { + "material": "minecraft:amethyst", + "pattern": "minecraft:coast" + } + }, + "customAnimatedDyes": { + "f1391873-5126-496d-b0fe-c861faeaf681": { + "color1": 16711680, + "color2": 11154282, + "samples": 10, + "cycleBack": true, + "tickDelay": 4 + } + } + }, + "uiAndVisuals": { + "compactorDeletorPreview": true, + "dontStripSkinAlphaValues": true, + "backpackPreviewWithoutShift": true, + "fancyCraftingTable": true, + "hideStatusEffectOverlay": false, + "chestValue": { + "enableChestValue": true, + "color": "DARK_GREEN", + "incompleteColor": "BLUE" + }, + "itemCooldown": { + "enableItemCooldowns": true + }, + "titleContainer": { + "titleContainerScale": 100.0, + "x": 482, + "y": 170, + "direction": "VERTICAL", + "alignment": "MIDDLE" + }, + "tabHud": { + "tabHudEnabled": true, + "tabHudScale": 100, + "enableHudBackground": true, + "plainPlayerNames": false, + "nameSorting": "ALPHABETICAL" + }, + "fancyAuctionHouse": { + "enabled": true, + "highlightCheapBIN": true + }, + "bars": { + "enableBars": true, + "barPositions": { + "healthBarPosition": "LAYER1", + "manaBarPosition": "LAYER1", + "defenceBarPosition": "RIGHT", + "experienceBarPosition": "RIGHT" + } + }, + "waypoints": { + "enableWaypoints": true, + "waypointType": "WAYPOINT" + }, + "teleportOverlay": { + "enableTeleportOverlays": true, + "enableWeirdTransmission": true, + "enableInstantTransmission": true, + "enableEtherTransmission": true, + "enableSinrecallTransmission": true, + "enableWitherImpact": true + }, + "searchOverlay": { + "enableBazaar": true, + "enableAuctionHouse": true, + "keepPreviousSearches": false, + "maxSuggestions": 5, + "historyLength": 5, + "enableCommands": false, + "bazaarHistory": [ + "Enchanted Snow Block", + "Recombobulator 3000", + "Enchanted Snow Block", + "Recombobulator 3000", + "Enchanted Snow Block" + ], + "auctionHistory": [ + "God Potion", + "New Year Cake (Year 30", + "New Year Cake (Year 31", + "New Year Cake (Year 32", + "New Year Cake (Year 2" + ] + }, + "flameOverlay": { + "flameHeight": 0, + "flameOpacity": 0 + }, + "hideEmptyTooltips": true + }, + "helpers": { + "enableNewYearCakesHelper": true, + "mythologicalRitual": { + "enableMythologicalRitualHelper": true + }, + "experiments": { + "enableChronomatronSolver": true, + "enableSuperpairsSolver": true, + "enableUltrasequencerSolver": true + }, + "fishing": { + "enableFishingHelper": true, + "enableFishingTimer": false, + "changeTimerColor": true, + "fishingTimerScale": 1.0, + "hideOtherPlayersRods": false + }, + "fairySouls": { + "enableFairySoulsHelper": true, + "highlightFoundSouls": false, + "highlightOnlyNearbySouls": false + } + }, + "dungeons": { + "fancyPartyFinder": true, + "croesusHelper": true, + "playerSecretsTracker": true, + "starredMobGlow": true, + "starredMobBoundingBoxes": true, + "allowDroppingProtectedItems": false, + "dungeonMap": { + "enableMap": true, + "mapScaling": 1.0, + "mapX": 2, + "mapY": 2 + }, + "puzzleSolvers": { + "solveThreeWeirdos": true, + "blazeSolver": true, + "creeperSolver": true, + "solveTrivia": true, + "solveTicTacToe": true, + "solveWaterboard": true, + "solveBoulder": true, + "solveIceFill": true, + "solveSilverfish": true + }, + "theProfessor": { + "fireFreezeStaffTimer": true, + "floor3GuardianHealthDisplay": true + }, + "livid": { + "enableLividColorGlow": true, + "enableLividColorText": true, + "enableLividColorTitle": true, + "lividColorText": "[color] is sus" + }, + "terminals": { + "solveColor": true, + "solveOrder": true, + "solveStartsWith": true + }, + "secretWaypoints": { + "enableRoomMatching": true, + "enableSecretWaypoints": true, + "waypointType": "OUTLINED_HIGHLIGHT", + "showSecretText": true, + "enableEntranceWaypoints": true, + "enableSuperboomWaypoints": true, + "enableChestWaypoints": true, + "enableItemWaypoints": true, + "enableBatWaypoints": true, + "enableWitherWaypoints": true, + "enableLeverWaypoints": true, + "enableFairySoulWaypoints": true, + "enableStonkWaypoints": false, + "enableAotvWaypoints": true, + "enablePearlWaypoints": true, + "enableDefaultWaypoints": true + }, + "mimicMessage": { + "sendMimicMessage": true, + "mimicMessage": "Mimic dead!" + }, + "doorHighlight": { + "enableDoorHighlight": true, + "doorHighlightType": "OUTLINED_HIGHLIGHT" + }, + "dungeonScore": { + "enableDungeonScore270Message": false, + "enableDungeonScore270Title": false, + "enableDungeonScore270Sound": false, + "dungeonScore270Message": "270 Score Reached!", + "enableDungeonScore300Message": true, + "enableDungeonScore300Title": true, + "enableDungeonScore300Sound": true, + "dungeonScore300Message": "[做得好] 300 Social Credit has been added to your account. Enjoy your boss fight.", + "enableDungeonCryptsMessage": true, + "dungeonCryptsMessageThreshold": 250, + "dungeonCryptsMessage": "We only have [crypts] crypts out of 5, we need more!", + "enableScoreHUD": true, + "scoreX": 25, + "scoreY": 134, + "scoreScaling": 1.0 + }, + "dungeonChestProfit": { + "enableProfitCalculator": true, + "includeKismet": true, + "includeEssence": false, + "croesusProfit": true, + "neutralThreshold": 1000, + "neutralColor": "DARK_GRAY", + "profitColor": "DARK_GREEN", + "lossColor": "RED", + "incompleteColor": "BLUE" + } + }, + "crimsonIsle": { + "kuudra": { + "supplyWaypoints": true, + "fuelWaypoints": true, + "suppliesAndFuelWaypointType": "WAYPOINT", + "ballistaBuildWaypoints": true, + "safeSpotWaypoints": true, + "pearlWaypoints": true, + "noArrowPoisonWarning": true, + "arrowPoisonThreshold": 16 + } + }, + "mining": { + "enableDrillFuel": true, + "dwarvenMines": { + "solveFetchur": true, + "solvePuzzler": true + }, + "dwarvenHud": { + "enabledCommissions": true, + "enabledPowder": true, + "style": "SIMPLE", + "commissionsX": 10, + "commissionsY": 10, + "powderX": 10, + "powderY": 70 + }, + "crystalsHud": { + "enabled": true, + "showLocations": true, + "locationSize": 8, + "x": 10, + "y": 130, + "mapScaling": 1.0 + }, + "crystalsWaypoints": { + "enabled": true, + "findInChat": true + }, + "crystalHollows": { + "metalDetectorHelper": true + } + }, + "farming": { + "garden": { + "farmingHud": { + "enableHud": true, + "x": 180, + "y": 0 + }, + "dicerTitlePrevent": true, + "visitorHelper": true, + "lockMouseTool": true, + "lockMouseGroundOnly": true + } + }, + "otherLocations": { + "barn": { + "solveHungryHiker": true, + "solveTreasureHunter": true + }, + "rift": { + "mirrorverseWaypoints": true, + "blobbercystGlow": true, + "enigmaSoulWaypoints": false, + "highlightFoundEnigmaSouls": true, + "mcGrubberStacks": 0 + }, + "end": { + "enableEnderNodeHelper": true, + "hudEnabled": true, + "zealotKillsEnabled": true, + "protectorLocationEnabled": true, + "waypoint": true, + "x": 10, + "y": 10 + }, + "spidersDen": { + "relics": { + "enableRelicsHelper": true, + "highlightFoundRelics": false + } + } + }, + "slayers": { + "endermanSlayer": { + "enableYangGlyphsNotification": true, + "highlightBeacons": true, + "highlightNukekubiHeads": true + }, + "vampireSlayer": { + "enableEffigyWaypoints": true, + "compactEffigyWaypoints": false, + "effigyUpdateFrequency": 5, + "enableHolyIceIndicator": true, + "holyIceIndicatorTickDelay": 10, + "holyIceUpdateFrequency": 5, + "enableHealingMelonIndicator": true, + "healingMelonHealthThreshold": 4.0, + "enableSteakStakeIndicator": true, + "steakStakeUpdateFrequency": 5, + "enableManiaIndicator": true, + "maniaUpdateFrequency": 5 + } + }, + "chat": { + "hideAbility": "ACTION_BAR", + "hideHeal": "PASS", + "hideAOTE": "ACTION_BAR", + "hideImplosion": "PASS", + "hideMoltenWave": "PASS", + "hideAds": "FILTER", + "hideTeleportPad": "PASS", + "hideCombo": "PASS", + "hideAutopet": "PASS", + "hideShowOff": "FILTER", + "hideToggleSkyMall": "PASS", + "hideMimicKill": "PASS", + "hideDeath": "PASS", + "hideMana": false, + "hideDicer": "PASS", + "chatRuleConfig": { + "announcementLength": 60, + "announcementScale": 3 + } + }, + "quickNav": { + "enableQuickNav": true, + "button8": { + "render": true, + "uiTitle": "none", + "clickEvent": "/hub", + "itemData": { + "count": 1, + "components": "[minecraft:profile\u003d{id:[I;-300151517,-631415889,-1193921967,-1821784279],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0\u003d\"}]}]", + "item": "minecraft:player_head" + } + }, + "button9": { + "render": true, + "uiTitle": "none", + "clickEvent": "/warp dungeon_hub", + "itemData": { + "count": 1, + "components": "[minecraft:profile\u003d{id:[I;1605800870,415127827,-1236127084,15358548],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MWQ1YjI3M2ZmMGJjNTBjOTYwYjJjZDg2ZWVmMWM0MGExYjk0MDMyYWU3MWU3NTQ3NWE1NjhhODI1NzQyMSJ9fX0\u003d\"}]}]", + "item": "minecraft:player_head" + } + }, + "button3": { + "render": true, + "uiTitle": "Pets(:? \\(\\d+\\/\\d+\\))?", + "clickEvent": "/pets", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:bone" + } + }, + "button4": { + "render": true, + "uiTitle": "Wardrobe \\([12]/2\\)", + "clickEvent": "/wardrobe", + "itemData": { + "count": 1, + "components": "[minecraft:dyed_color\u003d{rgb:8991416}]", + "item": "minecraft:leather_chestplate" + } + }, + "button5": { + "render": true, + "uiTitle": "Sack of Sacks", + "clickEvent": "/sacks", + "itemData": { + "count": 1, + "components": "[minecraft:profile\u003d{id:[I;-2081424676,-57521078,-2073572414,158072763],name:\"\",properties:[{name:\"textures\",value:\"ewogICJ0aW1lc3RhbXAiIDogMTU5MTMxMDU4NTYwOSwKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBhMDc3ZTI0OGQxNDI3NzJlYTgwMDg2NGY4YzU3OGI5ZDM2ODg1YjI5ZGFmODM2YjY0YTcwNjg4MmI2ZWMxMCIKICAgIH0KICB9Cn0\u003d\"}]}]", + "item": "minecraft:player_head" + } + }, + "button6": { + "render": true, + "uiTitle": "Storage", + "clickEvent": "/storage", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:ender_chest" + } + }, + "button1": { + "render": true, + "uiTitle": "Your Skills", + "clickEvent": "/skills", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:diamond_sword" + } + }, + "button2": { + "render": true, + "uiTitle": "Collections", + "clickEvent": "/collection", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:painting" + } + }, + "button11": { + "render": true, + "uiTitle": "Enchant Item", + "clickEvent": "/etable", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:enchanting_table" + } + }, + "button10": { + "render": true, + "uiTitle": "Visit prtl", + "clickEvent": "/visit prtl", + "itemData": { + "count": 1, + "components": "[minecraft:profile\u003d{id:[I;-562285948,532499670,-1705302742,775653035],name:\"\",properties:[{name:\"textures\",value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjVkZjU1NTkyNjQzMGQ1ZDc1YWRlZDIxZGQ5NjE5Yjc2YzViN2NhMmM3ZjU0MDE0NDA1MjNkNTNhOGJjZmFhYiJ9fX0\u003d\"}]}]", + "item": "minecraft:player_head" + } + }, + "button13": { + "render": true, + "uiTitle": "Craft Item", + "clickEvent": "/craft", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:crafting_table" + } + }, + "button12": { + "render": true, + "uiTitle": "Anvil", + "clickEvent": "/anvil", + "itemData": { + "count": 1, + "components": "[]", + "item": "minecraft:anvil" + } + } + }, + "misc": { + "richPresence": { + "enableRichPresence": false, + "info": "LOCATION", + "cycleMode": false, + "customMessage": "Playing Skyblock" + } + } +} \ No newline at end of file From 490122659180e912ac4a4d53e23630380c4bd1e3 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Wed, 15 May 2024 16:47:10 -0400 Subject: [PATCH 06/10] Fix defaults and lang --- .../skyblocker/config/configs/QuickNavigationConfig.java | 6 +++--- src/main/resources/assets/skyblocker/lang/en_us.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 548354c7e8..20a0c9cc10 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java @@ -33,7 +33,7 @@ public class QuickNavigationConfig { public QuickNavItem button5 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;-2081424676,-57521078,-2073572414,158072763],name:\"\",properties:[{name:\"textures\",value:\"ewogICJ0aW1lc3RhbXAiIDogMTU5MTMxMDU4NTYwOSwKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBhMDc3ZTI0OGQxNDI3NzJlYTgwMDg2NGY4YzU3OGI5ZDM2ODg1YjI5ZGFmODM2YjY0YTcwNjg4MmI2ZWMxMCIKICAgIH0KICB9Cn0=\"}]}]"), "Sack of Sacks", "/sacks"); @SerialEntry - public QuickNavItem button6 = new QuickNavItem(true, new ItemData("player_head", 1, "[\"minecraft:profile\":{\"name\":\"5da6bec64bd942bc\",\"id\":[1571208902,1272529596,-1566400349,-679283814],\"properties\":[{\"name\":\"textures\",\"value\":\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTYxYTkxOGMwYzQ5YmE4ZDA1M2U1MjJjYjkxYWJjNzQ2ODkzNjdiNGQ4YWEwNmJmYzFiYTkxNTQ3MzA5ODVmZiJ9fX0\\u003d\"}]}]"), "Accessory Bag(?: \\(\\d/\\d\\))?", "/accessories"); + public QuickNavItem button6 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={name:\"5da6bec64bd942bc\",id:[I;1571208902,1272529596,-1566400349,-679283814],properties:[{name:\"textures\",value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTYxYTkxOGMwYzQ5YmE4ZDA1M2U1MjJjYjkxYWJjNzQ2ODkzNjdiNGQ4YWEwNmJmYzFiYTkxNTQ3MzA5ODVmZiJ9fX0=\"}]}]"), "Accessory Bag(?: \\(\\d/\\d\\))?", "/accessories"); /* REGEX Explanation * "(?:Rift )?" : optional match on the non-capturing group "Rift " @@ -44,10 +44,10 @@ public class QuickNavigationConfig { public QuickNavItem button7 = new QuickNavItem(true, new ItemData("ender_chest"), "(?:Rift )?Storage(?: \\(\\d/\\d\\))?", "/storage"); @SerialEntry - public QuickNavItem button8 = new QuickNavItem(true, new ItemData("player_head", 1, "[\"minecraft:profile\":{\"name\":\"421a8ef40eff47f4\",\"id\":[1109036788,251611124,-2126904485,-130621758],\"properties\":[{\"name\":\"textures\",\"value\":\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0\\u003d\"}]}]"), "", "/is"); + public QuickNavItem button8 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={name:\"421a8ef40eff47f4\",id:[I;1109036788,251611124,-2126904485,-130621758],properties:[{name:\"textures\",value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0=\"}]}]"), "", "/is"); @SerialEntry - public QuickNavItem button9 = new QuickNavItem(true, new ItemData("player_head", 1, "[\"minecraft:profile\":{\"name\":\"e30e30d02878417c\",\"id\":[-485609264,678969724,-1929747597,-718202427],\"properties\":[{\"name\":\"textures\",\"value\":\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjQ4ODBkMmMxZTdiODZlODc1MjJlMjA4ODI2NTZmNDViYWZkNDJmOTQ5MzJiMmM1ZTBkNmVjYWE0OTBjYjRjIn19fQ\\u003d\\u003d\"}]}]"), "", "/warp garden"); + public QuickNavItem button9 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={name:\"e30e30d02878417c\",id:[I;-485609264,678969724,-1929747597,-718202427],properties:[{name:\"textures\",value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjQ4ODBkMmMxZTdiODZlODc1MjJlMjA4ODI2NTZmNDViYWZkNDJmOTQ5MzJiMmM1ZTBkNmVjYWE0OTBjYjRjIn19fQ==\"}]}]"), "", "/warp garden"); @SerialEntry public QuickNavItem button10 = new QuickNavItem(true, new ItemData("player_head", 1, "[minecraft:profile={id:[I;-300151517,-631415889,-1193921967,-1821784279],name:\"\",properties:[{name:\"textures\",value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0=\"}]}]"), "none", "/hub"); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index a945dfcd0c..4f00ff0790 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -477,7 +477,7 @@ "skyblocker.config.quickNav.button.item.components": "Item Components", "skyblocker.config.quickNav.button.item.components.@Tooltip": "A string of item components enclosed in square brackets, which is the same format as the /give command.\n\nExample: [minecraft:enchantment_glint_override=true]", "skyblocker.config.quickNav.button.item.count": "Item Count", - "skyblocker.config.quickNav.button.item.itemName": "Item ID", + "skyblocker.config.quickNav.button.item.itemName": "Item", "skyblocker.config.quickNav.button.render": "Render", "skyblocker.config.quickNav.button.uiTitle": "UI Title", "skyblocker.config.quickNav.enableQuickNav": "Enable Quick Navigation", From ca1565185771b9a3ca0907bc4c6e4f7351fbd505 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 16 May 2024 14:42:59 -0400 Subject: [PATCH 07/10] Clean up imports --- .../de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 6 ------ src/main/java/de/hysky/skyblocker/utils/ItemUtils.java | 1 - 2 files changed, 7 deletions(-) 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 8a66996fcf..fbf6a5d8f9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -1,21 +1,15 @@ package de.hysky.skyblocker.skyblock.quicknav; import com.mojang.brigadier.exceptions.CommandSyntaxException; - import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.QuickNavigationConfig; import de.hysky.skyblocker.utils.Constants; -import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.datafixer.ItemStackComponentizationFixer; -import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; -import net.fabricmc.fabric.api.client.screen.v1.Screens; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index 6a2af75108..1aa7708045 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -1,6 +1,5 @@ package de.hysky.skyblocker.utils; -import com.google.gson.Gson; import com.google.gson.JsonParser; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; From 7ea1157e5d1d0c41e2b5b51c8b80ead9ff20fcd0 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 18 May 2024 14:45:37 -0400 Subject: [PATCH 08/10] Upgrade all buttons --- .../config/datafixer/ConfigFix1.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java index e8198d7706..8eff09e7ec 100644 --- a/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java +++ b/src/main/java/de/hysky/skyblocker/config/datafixer/ConfigFix1.java @@ -1,8 +1,6 @@ package de.hysky.skyblocker.config.datafixer; import com.mojang.datafixers.DSL; -import com.mojang.datafixers.DataFix; -import com.mojang.datafixers.DataFixUtils; import com.mojang.datafixers.TypeRewriteRule; import com.mojang.datafixers.schemas.Schema; import com.mojang.logging.LogUtils; @@ -176,19 +174,9 @@ private static Dynamic fixChat(Dynamic dynamic) { } private static Dynamic fixQuickNav(Dynamic dynamic) { - return dynamic.update("quickNav", quickNav -> quickNav - .update("button1", ConfigFix1::fixQuickNavButton) - .update("button2", ConfigFix1::fixQuickNavButton) - .update("button3", ConfigFix1::fixQuickNavButton) - .update("button4", ConfigFix1::fixQuickNavButton) - .update("button5", ConfigFix1::fixQuickNavButton) - .update("button6", ConfigFix1::fixQuickNavButton) - .update("button7", ConfigFix1::fixQuickNavButton) - .update("button8", ConfigFix1::fixQuickNavButton) - .update("button9", ConfigFix1::fixQuickNavButton) - .update("button10", ConfigFix1::fixQuickNavButton) - .update("button11", ConfigFix1::fixQuickNavButton) - .update("button12", ConfigFix1::fixQuickNavButton)); + return dynamic.update("quickNav", quickNav -> quickNav.updateMapValues(button -> + button.getFirst().asString().getOrThrow().startsWith("button") ? button.mapSecond(ConfigFix1::fixQuickNavButton) : button + )); } private static Dynamic fixQuickNavButton(Dynamic button) { From 874a2f809d796d436462479d95a12e0b7d747703 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 18 May 2024 15:11:33 -0400 Subject: [PATCH 09/10] Add null safety --- .../java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 fbf6a5d8f9..2f73f7a959 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -8,6 +8,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import org.slf4j.Logger; @@ -46,9 +47,9 @@ public static List init(String screenTitle) { private static QuickNavButton parseButton(QuickNavigationConfig.QuickNavItem buttonInfo, String screenTitle, int id) throws CommandSyntaxException { QuickNavigationConfig.ItemData itemData = buttonInfo.itemData; - ItemStack stack = ItemStackComponentizationFixer.fromComponentsString(itemData.item.toString(), Math.clamp(itemData.count, 1, 99), itemData.components); - boolean uiTitleMatches = false; + ItemStack stack = itemData != null && itemData.item != null && itemData.components != null ? ItemStackComponentizationFixer.fromComponentsString(itemData.item.toString(), Math.clamp(itemData.count, 1, 99), itemData.components) : new ItemStack(Items.BEDROCK); + boolean uiTitleMatches = false; try { uiTitleMatches = screenTitle.matches(buttonInfo.uiTitle); } catch (PatternSyntaxException e) { From c155b6532531fd2de49ced44b12730571d740432 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 20 May 2024 14:35:41 -0400 Subject: [PATCH 10/10] Update default to barrier --- .../java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2f73f7a959..5fa517cca7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -47,7 +47,7 @@ public static List init(String screenTitle) { private static QuickNavButton parseButton(QuickNavigationConfig.QuickNavItem buttonInfo, String screenTitle, int id) throws CommandSyntaxException { QuickNavigationConfig.ItemData itemData = buttonInfo.itemData; - ItemStack stack = itemData != null && itemData.item != null && itemData.components != null ? ItemStackComponentizationFixer.fromComponentsString(itemData.item.toString(), Math.clamp(itemData.count, 1, 99), itemData.components) : new ItemStack(Items.BEDROCK); + ItemStack stack = itemData != null && itemData.item != null && itemData.components != null ? ItemStackComponentizationFixer.fromComponentsString(itemData.item.toString(), Math.clamp(itemData.count, 1, 99), itemData.components) : new ItemStack(Items.BARRIER); boolean uiTitleMatches = false; try {