From 4a43b965bb0b105eb5c614932f965449e930f56b Mon Sep 17 00:00:00 2001
From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Date: Sat, 9 Mar 2024 16:56:14 -0500
Subject: Refactor Hud Config Screens and fix dragging
---
.../hysky/skyblocker/config/HudConfigScreen.java | 128 +++++++++++++++------
.../hysky/skyblocker/config/SkyblockerConfig.java | 24 +++-
.../config/categories/DwarvenMinesCategory.java | 7 --
.../config/categories/GeneralCategory.java | 8 ++
.../config/categories/LocationsCategory.java | 22 ++--
5 files changed, 134 insertions(+), 55 deletions(-)
(limited to 'src/main/java/de/hysky/skyblocker/config')
diff --git a/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java b/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
index c33e2f54..6884af83 100644
--- a/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
+++ b/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
@@ -2,82 +2,142 @@ package de.hysky.skyblocker.config;
import de.hysky.skyblocker.skyblock.tabhud.widget.Widget;
import de.hysky.skyblocker.utils.render.RenderHelper;
-import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
-import it.unimi.dsi.fastutil.ints.IntIntPair;
+import it.unimi.dsi.fastutil.ints.IntIntMutablePair;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
+import net.minecraft.util.math.MathHelper;
import java.awt.*;
+import java.util.List;
+/**
+ * A screen for configuring the positions of HUD widgets.
+ *
+ * This class takes care of rendering the widgets, dragging them, and resetting their positions.
+ * Create one subclass for each collection of HUD widgets that are displayed at the same time.
+ * (i.e. one for dwarven mines, one for the end, etc.) See an implementation for an example.
+ */
public abstract class HudConfigScreen extends Screen {
- private final Widget widget;
private final Screen parent;
+ private final List widgets;
- private int hudX = 0;
- private int hudY = 0;
- public HudConfigScreen(Text title, Widget widget, Screen parent) {
+ private Widget draggingWidget;
+ private double mouseClickRelativeX;
+ private double mouseClickRelativeY;
+
+ /**
+ * Creates a new HudConfigScreen with the passed title, parent, and widget
+ * @param title the title of the screen
+ * @param parent the parent screen
+ * @param widget the widget to configure
+ */
+ public HudConfigScreen(Text title, Screen parent, Widget widget) {
+ this(title, parent, List.of(widget));
+ }
+
+ /**
+ * Creates a new HudConfigScreen with the passed title, parent, and widgets
+ * @param title the title of the screen
+ * @param parent the parent screen
+ * @param widgets the widgets to configure
+ */
+ public HudConfigScreen(Text title, Screen parent, List widgets) {
super(title);
- this.widget = widget;
this.parent = parent;
-
- int[] posFromConfig = getPosFromConfig(SkyblockerConfigManager.get());
- hudX = posFromConfig[0];
- hudY = posFromConfig[1];
+ this.widgets = widgets;
+ resetPos();
}
@Override
- public void render(DrawContext context, int mouseX, int mouseY, float delta) {
+ public final void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
renderBackground(context, mouseX, mouseY, delta);
- renderWidget(context, hudX, hudY);
+ renderWidget(context, widgets);
context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
}
+ /**
+ * Renders the widgets using the default {@link Widget#render(DrawContext, boolean)} method. Override to change the behavior.
+ * @param context the context to render in
+ * @param widgets the widgets to render
+ */
+ protected void renderWidget(DrawContext context, List widgets) {
+ for (Widget widget : widgets) {
+ widget.render(context, SkyblockerConfigManager.get().general.tabHud.enableHudBackground);
+ }
+ }
+
@Override
- public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
- IntIntPair dims = getDimensions();
- if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + dims.leftInt(), hudY + dims.rightInt()) && button == 0) {
- hudX = (int) Math.max(Math.min(mouseX - (double) dims.leftInt() / 2, this.width - dims.leftInt()), 0);
- hudY = (int) Math.max(Math.min(mouseY - (double) dims.rightInt() / 2, this.height - dims.rightInt()), 0);
+ public final boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
+ if (button == 0 && draggingWidget != null) {
+ draggingWidget.setX((int) MathHelper.clamp(mouseX - mouseClickRelativeX, 0, this.width - draggingWidget.getWidth()));
+ draggingWidget.setY((int) MathHelper.clamp(mouseY - mouseClickRelativeY, 0, this.height - draggingWidget.getHeight()));
}
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
@Override
- public boolean mouseClicked(double mouseX, double mouseY, int button) {
- if (button == 1) {
- IntIntPair dims = getDimensions();
- hudX = this.width / 2 - dims.leftInt();
- hudY = this.height / 2 - dims.rightInt();
+ public final boolean mouseClicked(double mouseX, double mouseY, int button) {
+ if (button == 0) {
+ for (Widget widget : widgets) {
+ if (RenderHelper.pointIsInArea(mouseX, mouseY, widget.getX(), widget.getY(), widget.getX() + widget.getWidth(), widget.getY() + widget.getHeight())) {
+ draggingWidget = widget;
+ mouseClickRelativeX = mouseX - widget.getX();
+ mouseClickRelativeY = mouseY - widget.getY();
+ break;
+ }
+ }
+ } else if (button == 1) {
+ resetPos();
}
return super.mouseClicked(mouseX, mouseY, button);
}
- abstract protected int[] getPosFromConfig(SkyblockerConfig config);
+ @Override
+ public final boolean mouseReleased(double mouseX, double mouseY, int button) {
+ draggingWidget = null;
+ return super.mouseReleased(mouseX, mouseY, button);
+ }
- protected IntIntPair getDimensions() {
- return new IntIntImmutablePair(widget.getHeight(), widget.getWidth());
+ /**
+ * Resets the positions of the widgets to the positions in the config. Override to change the behavior.
+ */
+ protected void resetPos() {
+ List configPositions = getConfigPos(SkyblockerConfigManager.get());
+ if (configPositions.size() != widgets.size()) {
+ throw new IllegalStateException("The number of positions (" + configPositions.size() + ") does not match the number of widgets (" + widgets.size() + ")");
+ }
+ for (int i = 0; i < widgets.size(); i++) {
+ Widget widget = widgets.get(i);
+ IntIntMutablePair configPos = configPositions.get(i);
+ widget.setX(configPos.leftInt());
+ widget.setY(configPos.rightInt());
+ }
}
+ /**
+ * Returns the positions of the widgets in the config
+ * @param config the config to get the positions from
+ * @return the positions of the widgets
+ */
+ protected abstract List getConfigPos(SkyblockerConfig config);
+
@Override
- public void close() {
+ public final void close() {
SkyblockerConfig skyblockerConfig = SkyblockerConfigManager.get();
- savePos(skyblockerConfig, hudX, hudY);
+ savePos(skyblockerConfig, widgets);
SkyblockerConfigManager.save();
client.setScreen(parent);
}
/**
- * This method should save the passed position to the config
+ * Saves the passed positions to the config.
*
* NOTE: The parent class will call {@link SkyblockerConfigManager#save()} right after this method
* @param configManager the config so you don't have to get it
- * @param x x
- * @param y y
+ * @param widgets the widgets to save
*/
- abstract protected void savePos(SkyblockerConfig configManager, int x, int y);
-
- abstract protected void renderWidget(DrawContext context, int x, int y);
+ protected abstract void savePos(SkyblockerConfig configManager, List widgets);
}
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
index 9db212c1..e60aa03b 100644
--- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
+++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
@@ -266,6 +266,9 @@ public class SkyblockerConfig {
@SerialEntry
public int tabHudScale = 100;
+ @SerialEntry
+ public boolean enableHudBackground = true;
+
@SerialEntry
public boolean plainPlayerNames = false;
@@ -941,9 +944,6 @@ public class SkyblockerConfig {
@SerialEntry
public DwarvenHudStyle style = DwarvenHudStyle.SIMPLE;
- @SerialEntry
- public boolean enableBackground = true;
-
@SerialEntry
public int x = 10;
@@ -1059,9 +1059,6 @@ public class SkyblockerConfig {
@SerialEntry
public boolean hudEnabled = true;
- @SerialEntry
- public boolean enableBackground = true;
-
@SerialEntry
public boolean waypoint = true;
@@ -1086,6 +1083,9 @@ public class SkyblockerConfig {
}
public static class Garden {
+ @SerialEntry
+ public FarmingHud farmingHud = new FarmingHud();
+
@SerialEntry
public boolean dicerTitlePrevent = true;
@@ -1093,6 +1093,17 @@ public class SkyblockerConfig {
public boolean visitorHelper = true;
}
+ public static class FarmingHud {
+ @SerialEntry
+ public boolean enableHud = true;
+
+ @SerialEntry
+ public int x;
+
+ @SerialEntry
+ public int y;
+ }
+
public static class Slayer {
@SerialEntry
public EndermanSlayer endermanSlayer = new EndermanSlayer();
@@ -1196,6 +1207,7 @@ public class SkyblockerConfig {
@SerialEntry
public ChatRuleConfig chatRuleConfig = new ChatRuleConfig();
}
+
public static class ChatRuleConfig {
@SerialEntry
public int announcementLength = 60;
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java
index 97b48bc4..4ae0fc35 100644
--- a/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java
+++ b/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java
@@ -76,13 +76,6 @@ public class DwarvenMinesCategory {
.text(Text.translatable("text.skyblocker.open"))
.action((screen, opt) -> MinecraftClient.getInstance().setScreen(new DwarvenHudConfigScreen(screen)))
.build())
- .option(Option.createBuilder()
- .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.enableBackground"))
- .binding(defaults.locations.dwarvenMines.dwarvenHud.enableBackground,
- () -> config.locations.dwarvenMines.dwarvenHud.enableBackground,
- newValue -> config.locations.dwarvenMines.dwarvenHud.enableBackground = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
.build())
//crystal HUD
.group(OptionGroup.createBuilder()
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java
index afd688d8..23ce7bb6 100644
--- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java
+++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java
@@ -106,6 +106,14 @@ public class GeneralCategory {
newValue -> config.general.tabHud.tabHudScale = newValue)
.controller(opt -> IntegerSliderControllerBuilder.create(opt).range(10, 200).step(1))
.build())
+ .option(Option.createBuilder()
+ .name(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud.enableHudBackground"))
+ .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud.enableHudBackground.@Tooltip")))
+ .binding(defaults.general.tabHud.enableHudBackground,
+ () -> config.general.tabHud.enableHudBackground,
+ newValue -> config.general.tabHud.enableHudBackground = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
.option(Option.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud.plainPlayerNames"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.tabHud.plainPlayerNames.@Tooltip")))
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java
index d97513f8..86ed3f6c 100644
--- a/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java
+++ b/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java
@@ -4,6 +4,7 @@ import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.skyblock.end.EndHudConfigScreen;
import de.hysky.skyblocker.skyblock.end.TheEnd;
+import de.hysky.skyblocker.skyblock.garden.FarmingHudConfigScreen;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import net.minecraft.client.MinecraftClient;
@@ -90,13 +91,6 @@ public class LocationsCategory {
newValue -> config.locations.end.hudEnabled = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
- .option(Option.createBuilder()
- .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.enableBackground")) // Reusing that string cuz sure
- .binding(defaults.locations.end.enableBackground,
- () -> config.locations.end.enableBackground,
- newValue -> config.locations.end.enableBackground = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
.option(Option.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.end.waypoint"))
.binding(defaults.locations.end.waypoint,
@@ -146,6 +140,18 @@ public class LocationsCategory {
.group(OptionGroup.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.garden"))
.collapsed(false)
+ .option(Option.createBuilder()
+ .name(Text.translatable("text.autoconfig.skyblocker.option.locations.garden.farmingHud.enableHud"))
+ .binding(defaults.locations.garden.farmingHud.enableHud,
+ () -> config.locations.garden.farmingHud.enableHud,
+ newValue -> config.locations.garden.farmingHud.enableHud = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(ButtonOption.createBuilder()
+ .name(Text.translatable("text.autoconfig.skyblocker.option.locations.garden.farmingHud.config"))
+ .text(Text.translatable("text.skyblocker.open"))
+ .action((screen, opt) -> MinecraftClient.getInstance().setScreen(new FarmingHudConfigScreen(screen)))
+ .build())
.option(Option.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.garden.dicerTitlePrevent"))
.binding(defaults.locations.garden.dicerTitlePrevent,
@@ -154,7 +160,7 @@ public class LocationsCategory {
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.createBuilder()
- .name(Text.translatable("text.autoconfig.skyblocker.option.general.visitorHelper"))
+ .name(Text.translatable("text.autoconfig.skyblocker.option.locations.garden.visitorHelper"))
.binding(defaults.locations.garden.visitorHelper,
() -> config.locations.garden.visitorHelper,
newValue -> config.locations.garden.visitorHelper = newValue)
--
cgit
From 477d26414d4f23c8b16aaa975fd78d4cd7f46c2c Mon Sep 17 00:00:00 2001
From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Date: Thu, 14 Mar 2024 20:20:40 -0400
Subject: Refactor Farming Hud
---
.../hysky/skyblocker/config/HudConfigScreen.java | 1 -
.../skyblocker/skyblock/garden/FarmingHud.java | 12 +++-
.../skyblock/garden/FarmingHudConfigScreen.java | 3 +-
.../skyblock/garden/FarmingHudWidget.java | 67 ++++++++++++++++++++++
.../tabhud/widget/hud/HudFarmingWidget.java | 65 ---------------------
5 files changed, 77 insertions(+), 71 deletions(-)
create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java
delete mode 100644 src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudFarmingWidget.java
(limited to 'src/main/java/de/hysky/skyblocker/config')
diff --git a/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java b/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
index 6884af83..07109b46 100644
--- a/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
+++ b/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java
@@ -52,7 +52,6 @@ public abstract class HudConfigScreen extends Screen {
@Override
public final void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
- renderBackground(context, mouseX, mouseY, delta);
renderWidget(context, widgets);
context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB());
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java
index dba282c1..ab504d6d 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java
@@ -1,14 +1,16 @@
package de.hysky.skyblocker.skyblock.garden;
+import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
-import de.hysky.skyblocker.skyblock.tabhud.widget.hud.HudFarmingWidget;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Location;
import de.hysky.skyblocker.utils.Utils;
+import de.hysky.skyblocker.utils.scheduler.Scheduler;
import it.unimi.dsi.fastutil.floats.FloatLongPair;
import it.unimi.dsi.fastutil.ints.IntLongPair;
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
import it.unimi.dsi.fastutil.longs.LongPriorityQueue;
+import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.event.client.player.ClientPlayerBlockBreakEvents;
@@ -26,6 +28,8 @@ import java.util.Queue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
+
public class FarmingHud {
private static final Logger LOGGER = LoggerFactory.getLogger(FarmingHud.class);
public static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);
@@ -62,8 +66,8 @@ public class FarmingHud {
}
}
- HudFarmingWidget.INSTANCE.update();
- HudFarmingWidget.INSTANCE.render(context, SkyblockerConfigManager.get().general.tabHud.enableHudBackground);
+ FarmingHudWidget.INSTANCE.update();
+ FarmingHudWidget.INSTANCE.render(context, SkyblockerConfigManager.get().general.tabHud.enableHudBackground);
}
});
ClientPlayerBlockBreakEvents.AFTER.register((world, player, pos, state) -> {
@@ -84,6 +88,8 @@ public class FarmingHud {
}
}
});
+ ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("hud").then(literal("farming")
+ .executes(Scheduler.queueOpenScreenCommand(() -> new FarmingHudConfigScreen(null)))))));
}
private static boolean shouldRender() {
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudConfigScreen.java
index 51c1c69e..5384d47a 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudConfigScreen.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudConfigScreen.java
@@ -3,7 +3,6 @@ package de.hysky.skyblocker.skyblock.garden;
import de.hysky.skyblocker.config.HudConfigScreen;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.skyblock.tabhud.widget.Widget;
-import de.hysky.skyblocker.skyblock.tabhud.widget.hud.HudFarmingWidget;
import it.unimi.dsi.fastutil.ints.IntIntMutablePair;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
@@ -12,7 +11,7 @@ import java.util.List;
public class FarmingHudConfigScreen extends HudConfigScreen {
public FarmingHudConfigScreen(Screen parent) {
- super(Text.literal("Farming HUD Config"), parent, HudFarmingWidget.INSTANCE);
+ super(Text.literal("Farming HUD Config"), parent, FarmingHudWidget.INSTANCE);
}
@SuppressWarnings("SuspiciousNameCombination")
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java
new file mode 100644
index 00000000..6ddb0e05
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java
@@ -0,0 +1,67 @@
+package de.hysky.skyblocker.skyblock.garden;
+
+import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import de.hysky.skyblocker.skyblock.tabhud.util.Ico;
+import de.hysky.skyblocker.skyblock.tabhud.widget.Widget;
+import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent;
+import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
+import de.hysky.skyblocker.utils.ItemUtils;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.item.ItemStack;
+import net.minecraft.text.MutableText;
+import net.minecraft.text.Text;
+import net.minecraft.util.Formatting;
+import net.minecraft.util.math.MathHelper;
+
+import java.util.Map;
+
+public class FarmingHudWidget extends Widget {
+ private static final MutableText TITLE = Text.literal("Farming").formatted(Formatting.YELLOW, Formatting.BOLD);
+ private static final Map FARMING_TOOLS = Map.ofEntries(
+ Map.entry("THEORETICAL_HOE_WHEAT_1", Ico.WHEAT),
+ Map.entry("THEORETICAL_HOE_WHEAT_2", Ico.WHEAT),
+ Map.entry("THEORETICAL_HOE_WHEAT_3", Ico.WHEAT),
+ Map.entry("THEORETICAL_HOE_CARROT_1", Ico.CARROT),
+ Map.entry("THEORETICAL_HOE_CARROT_2", Ico.CARROT),
+ Map.entry("THEORETICAL_HOE_CARROT_3", Ico.CARROT),
+ Map.entry("THEORETICAL_HOE_POTATO_1", Ico.POTATO),
+ Map.entry("THEORETICAL_HOE_POTATO_2", Ico.POTATO),
+ Map.entry("THEORETICAL_HOE_POTATO_3", Ico.POTATO),
+ Map.entry("THEORETICAL_HOE_CANE_1", Ico.SUGAR_CANE),
+ Map.entry("THEORETICAL_HOE_CANE_2", Ico.SUGAR_CANE),
+ Map.entry("THEORETICAL_HOE_CANE_3", Ico.SUGAR_CANE),
+ Map.entry("THEORETICAL_HOE_WARTs_1", Ico.NETHER_WART),
+ Map.entry("THEORETICAL_HOE_WARTs_2", Ico.NETHER_WART),
+ Map.entry("THEORETICAL_HOE_WARTs_3", Ico.NETHER_WART),
+ Map.entry("FUNGI_CUTTER", Ico.MUSHROOM),
+ Map.entry("CACTUS_KNIFE", Ico.CACTUS),
+ Map.entry("MELON_DICER", Ico.MELON),
+ Map.entry("PUMPKIN_DICER", Ico.PUMPKIN),
+ Map.entry("COCO_CHOPPER", Ico.COCOA_BEANS)
+ );
+ public static final FarmingHudWidget INSTANCE = new FarmingHudWidget();
+ private final MinecraftClient client = MinecraftClient.getInstance();
+
+ public FarmingHudWidget() {
+ super(TITLE, Formatting.YELLOW.getColorValue());
+ setX(SkyblockerConfigManager.get().locations.garden.farmingHud.x);
+ setY(SkyblockerConfigManager.get().locations.garden.farmingHud.y);
+ update();
+ }
+
+ @SuppressWarnings("DataFlowIssue")
+ @Override
+ public void updateContent() {
+ ItemStack icon = FARMING_TOOLS.getOrDefault(ItemUtils.getItemId(client.player.getMainHandStack()), Ico.HOE);
+ addSimpleIcoText(icon, "Counter: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter()));
+ addSimpleIcoText(icon, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.cropsPerMinute() / 100 * 100));
+ addSimpleIcoText(icon, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks()));
+ addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue()));
+ addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour()));
+
+ double yaw = client.getCameraEntity().getYaw();
+ double pitch = client.getCameraEntity().getPitch();
+ addComponent(new PlainTextComponent(Text.literal("Yaw: " + String.format("%.3f", MathHelper.wrapDegrees(yaw))).formatted(Formatting.YELLOW)));
+ addComponent(new PlainTextComponent(Text.literal("Pitch: " + String.format("%.3f", MathHelper.wrapDegrees(pitch))).formatted(Formatting.YELLOW)));
+ }
+}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudFarmingWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudFarmingWidget.java
deleted file mode 100644
index 645bef96..00000000
--- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/hud/HudFarmingWidget.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package de.hysky.skyblocker.skyblock.tabhud.widget.hud;
-
-import de.hysky.skyblocker.skyblock.garden.FarmingHud;
-import de.hysky.skyblocker.skyblock.tabhud.util.Ico;
-import de.hysky.skyblocker.skyblock.tabhud.widget.Widget;
-import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent;
-import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent;
-import de.hysky.skyblocker.utils.ItemUtils;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.item.ItemStack;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-import net.minecraft.util.math.MathHelper;
-
-import java.util.Map;
-
-public class HudFarmingWidget extends Widget {
- private static final MutableText TITLE = Text.literal("Farming").formatted(Formatting.YELLOW, Formatting.BOLD);
- private static final Map FARMING_TOOLS = Map.ofEntries(
- Map.entry("THEORETICAL_HOE_WHEAT_1", Ico.WHEAT),
- Map.entry("THEORETICAL_HOE_WHEAT_2", Ico.WHEAT),
- Map.entry("THEORETICAL_HOE_WHEAT_3", Ico.WHEAT),
- Map.entry("THEORETICAL_HOE_CARROT_1", Ico.CARROT),
- Map.entry("THEORETICAL_HOE_CARROT_2", Ico.CARROT),
- Map.entry("THEORETICAL_HOE_CARROT_3", Ico.CARROT),
- Map.entry("THEORETICAL_HOE_POTATO_1", Ico.POTATO),
- Map.entry("THEORETICAL_HOE_POTATO_2", Ico.POTATO),
- Map.entry("THEORETICAL_HOE_POTATO_3", Ico.POTATO),
- Map.entry("THEORETICAL_HOE_CANE_1", Ico.SUGAR_CANE),
- Map.entry("THEORETICAL_HOE_CANE_2", Ico.SUGAR_CANE),
- Map.entry("THEORETICAL_HOE_CANE_3", Ico.SUGAR_CANE),
- Map.entry("THEORETICAL_HOE_WARTs_1", Ico.NETHER_WART),
- Map.entry("THEORETICAL_HOE_WARTs_2", Ico.NETHER_WART),
- Map.entry("THEORETICAL_HOE_WARTs_3", Ico.NETHER_WART),
- Map.entry("FUNGI_CUTTER", Ico.MUSHROOM),
- Map.entry("CACTUS_KNIFE", Ico.CACTUS),
- Map.entry("MELON_DICER", Ico.MELON),
- Map.entry("PUMPKIN_DICER", Ico.PUMPKIN),
- Map.entry("COCO_CHOPPER", Ico.COCOA_BEANS)
- );
- public static final HudFarmingWidget INSTANCE = new HudFarmingWidget();
- private final MinecraftClient client = MinecraftClient.getInstance();
-
- public HudFarmingWidget() {
- super(TITLE, Formatting.YELLOW.getColorValue());
- update();
- }
-
- @SuppressWarnings("DataFlowIssue")
- @Override
- public void updateContent() {
- ItemStack icon = FARMING_TOOLS.getOrDefault(ItemUtils.getItemId(client.player.getMainHandStack()), Ico.HOE);
- addSimpleIcoText(icon, "Counter: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter()));
- addSimpleIcoText(icon, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.cropsPerMinute() / 100 * 100));
- addSimpleIcoText(icon, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks()));
- addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue()));
- addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour()));
-
- double yaw = client.getCameraEntity().getYaw();
- double pitch = client.getCameraEntity().getPitch();
- addComponent(new PlainTextComponent(Text.literal("Yaw: " + String.format("%.3f", MathHelper.wrapDegrees(yaw))).formatted(Formatting.YELLOW)));
- addComponent(new PlainTextComponent(Text.literal("Pitch: " + String.format("%.3f", MathHelper.wrapDegrees(pitch))).formatted(Formatting.YELLOW)));
- }
-}
--
cgit