aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-05-15 12:36:30 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-05-15 12:36:30 -0400
commit0b0d8be21af814c47bf42ce70ca9902092024212 (patch)
tree6296c3b18d15ad909447685b2243c6575c95a4d0
parent964799fae2c0a6bcffdebc074a72a112e42039b9 (diff)
downloadSkyblocker-0b0d8be21af814c47bf42ce70ca9902092024212.tar.gz
Skyblocker-0b0d8be21af814c47bf42ce70ca9902092024212.tar.bz2
Skyblocker-0b0d8be21af814c47bf42ce70ca9902092024212.zip
Clean up rendering code and remove extra buttons option
-rw-r--r--src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java9
-rw-r--r--src/main/java/de/hysky/skyblocker/config/configs/QuickNavigationConfig.java2
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNav.java16
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java63
-rw-r--r--src/main/resources/assets/skyblocker/lang/en_us.json2
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 e6543daf..40541bea 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 class QuickNavigationCategory {
.controller(ConfigUtils::createBooleanController)
.build())
- //Enable Extended Quick Nav Buttons
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.quickNav.enableExtendedQuickNav"))
- .binding(defaults.quickNav.enableExtendedQuickNav,
- () -> config.quickNav.enableExtendedQuickNav,
- newValue -> config.quickNav.enableExtendedQuickNav = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
-
//Button 1
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.quickNav.button", 1))
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 173d2532..e4ecfc54 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 @@ import dev.isxander.yacl3.config.v2.api.SerialEntry;
public class QuickNavigationConfig {
@SerialEntry
public boolean enableQuickNav = true;
- @SerialEntry
- public boolean enableExtendedQuickNav = true;
@SerialEntry
public QuickNavItem button1 = new QuickNavItem(true, new ItemData("diamond_sword"), "Your Skills", "/skills");
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) {}
}
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index b73c7594..a945dfcd 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",