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: Machinika: Museum --- .../skyblocker/skyblock/quicknav/QuickNav.java | 4 ++ .../skyblock/quicknav/QuickNavButton.java | 68 +++++++++++++++------- 2 files changed, 51 insertions(+), 21 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java index a6adf66b..2c9d8305 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java @@ -51,6 +51,10 @@ public class QuickNav { if (data.button10.render) buttons.add(parseButton(data.button10, screenTitle, 9)); if (data.button11.render) buttons.add(parseButton(data.button11, screenTitle, 10)); if (data.button12.render) buttons.add(parseButton(data.button12, screenTitle, 11)); + if (SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + if (data.button13.render) buttons.add(parseButton(data.button13, screenTitle, 12)); + if (data.button14.render) buttons.add(parseButton(data.button14, screenTitle, 13)); + } } catch (CommandSyntaxException e) { LOGGER.error("[Skyblocker] Failed to initialize Quick Nav Button", e); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java index 7db78590..516aed32 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -25,18 +26,24 @@ public class QuickNavButton extends ClickableWidget { /** * Checks if the current tab is a top tab based on its index. + * * @return true if the index is less than 6, false otherwise. */ private boolean isTopTab() { - return index < 6; + if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + return index < 6; + } else { + return index < 7; + } } /** * Constructs a new QuickNavButton with the given parameters. - * @param index the index of the button. + * + * @param index the index of the button. * @param toggled the toggled state of the button. * @param command the command to execute when the button is clicked. - * @param icon the icon to display on the button. + * @param icon the icon to display on the button. */ public QuickNavButton(int index, boolean toggled, String command, ItemStack icon) { super(0, 0, 26, 32, Text.empty()); @@ -49,18 +56,24 @@ public class QuickNavButton extends ClickableWidget { private void updateCoordinates() { Screen screen = MinecraftClient.getInstance().currentScreen; if (screen instanceof HandledScreen handledScreen) { - int x = ((HandledScreenAccessor)handledScreen).getX(); - int y = ((HandledScreenAccessor)handledScreen).getY(); - int h = ((HandledScreenAccessor)handledScreen).getBackgroundHeight(); + int x = ((HandledScreenAccessor) handledScreen).getX(); + int y = ((HandledScreenAccessor) handledScreen).getY(); + int h = ((HandledScreenAccessor) handledScreen).getBackgroundHeight(); if (h > 166) --h; // why is this even a thing - this.setX(x + this.index % 6 * 26 + 4); - this.setY(this.index < 6 ? y - 26 : y + h - 4); + if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + this.setX(x + this.index % 6 * 26 + 4); + this.setY(this.index < 6 ? y - 26 : y + h - 4); + } else { + this.setX(x + this.index % 7 * 25); + this.setY(this.index < 7 ? y - 25 : y + h - 4); + } } } /** * Handles click events. If the button is not currently toggled, * it sets the toggled state to true and sends a message with the command after cooldown. + * * @param mouseX the x-coordinate of the mouse click * @param mouseY the y-coordinate of the mouse click */ @@ -78,9 +91,10 @@ public class QuickNavButton extends ClickableWidget { * The method first updates the coordinates of the button, * then calculates appropriate values for rendering based on its current state, * and finally draws both the background and icon of the button on screen. + * * @param context the context in which to render the button - * @param mouseX the x-coordinate of the mouse cursor - * @param mouseY the y-coordinate of the mouse cursor + * @param mouseX the x-coordinate of the mouse cursor + * @param mouseY the y-coordinate of the mouse cursor */ @Override public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { @@ -94,19 +108,31 @@ public class QuickNavButton extends ClickableWidget { // Render the button texture int y = this.getY(); - if (this.toggled) { - if (this.index < 6) y -= 2; - } else { - y += (this.index >= 6) ? 4 : -2; - } - int height = this.height - ((this.toggled ) ? 0 : 4); + if (!SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { + if (this.toggled) { + if (this.index < 6) y -= 2; + } else { + y += (this.index >= 6) ? 4 : -2; + } + int height = this.height - ((this.toggled) ? 0 : 4); - context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height); - - // Render the button icon - int yOffset = !this.toggled && this.index < 6 ? 1 : 0; - context.drawItem(this.icon, this.getX() + 5, this.getY() + 6 + yOffset); + context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width, height); + // Render the button icon + int yOffset = !this.toggled && this.index < 6 ? 1 : 0; + context.drawItem(this.icon, this.getX() + 5, this.getY() + 6 + yOffset); + } else { + if (this.toggled) { + if (this.index < 7) y -= 2; + } else { + y += (this.index >= 7) ? 4 : -2; + } + int height = this.height - ((this.toggled) ? 0 : 4); + context.drawGuiTexture(BUTTON_TEXTURES, this.getX(), y, this.width - 1, height); + // Render the button icon + int yOffset = !this.toggled && this.index < 7 ? 1 : 0; + context.drawItem(this.icon, this.getX() + 4, this.getY() + 6 + yOffset); + } RenderSystem.enableDepthTest(); } -- cgit 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: Adjusted Button Rendering with the help of BigloBot --- .../skyblocker/skyblock/quicknav/QuickNavButton.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 516aed32..d964cd3e 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 @@ public class QuickNavButton extends ClickableWidget { * @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 @@ public class QuickNavButton extends ClickableWidget { 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 class QuickNavButton extends ClickableWidget { } 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 class QuickNavButton extends ClickableWidget { RenderSystem.enableDepthTest(); } - @Override - protected void appendClickableNarrations(NarrationMessageBuilder builder) { - // TODO Auto-generated method stub + @Override + protected void appendClickableNarrations(NarrationMessageBuilder builder) { + // TODO Auto-generated method stub - } + } } -- cgit 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: Clean up rendering code and remove extra buttons option --- .../skyblocker/skyblock/quicknav/QuickNav.java | 16 +++--- .../skyblock/quicknav/QuickNavButton.java | 63 +++++----------------- 2 files changed, 18 insertions(+), 61 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 2c9d8305..cfa7b41b 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 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; @@ -51,10 +52,8 @@ public class QuickNav { if (data.button10.render) buttons.add(parseButton(data.button10, screenTitle, 9)); if (data.button11.render) buttons.add(parseButton(data.button11, screenTitle, 10)); if (data.button12.render) buttons.add(parseButton(data.button12, screenTitle, 11)); - if (SkyblockerConfigManager.get().quickNav.enableExtendedQuickNav) { - if (data.button13.render) buttons.add(parseButton(data.button13, screenTitle, 12)); - if (data.button14.render) buttons.add(parseButton(data.button14, screenTitle, 13)); - } + 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 @@ public class QuickNav { 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 d964cd3e..e2c5cb00 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.item.ItemStack; 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 @@ public class QuickNavButton extends ClickableWidget { * @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 @@ public class QuickNavButton extends ClickableWidget { 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 class QuickNavButton extends ClickableWidget { 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) {} } -- cgit 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: Add Quick Nav data fixer and refactor tabs --- .../de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 14 ++------------ .../hysky/skyblocker/skyblock/quicknav/QuickNavButton.java | 10 +++++++--- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 cfa7b41b..8a66996f 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 @@ import java.util.regex.PatternSyntaxException; 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 class QuickNav { } 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 e2c5cb00..f9ca0940 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 @@ public class QuickNavButton extends ClickableWidget { return index < 7; } + public boolean toggled() { + return toggled; + } + /** * Constructs a new QuickNavButton with the given parameters. * @@ -53,8 +57,8 @@ public class QuickNavButton extends ClickableWidget { 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 class QuickNavButton extends ClickableWidget { 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); -- cgit 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: Clean up imports --- src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 8a66996f..fbf6a5d8 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; -- cgit 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: Add null safety --- src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 fbf6a5d8..2f73f7a9 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 de.hysky.skyblocker.utils.datafixer.ItemStackComponentizationFixer; 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 class QuickNav { 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) { -- cgit 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: Update default to barrier --- src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') 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 2f73f7a9..5fa517cc 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 class QuickNav { 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 { -- cgit