aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYasin <19829407+LifeIsAParadox@users.noreply.github.com>2025-06-14 16:17:38 +0200
committerGitHub <noreply@github.com>2025-06-14 22:17:38 +0800
commitcd29a1475253ff3ca8098765875a45fdbefd75e7 (patch)
tree3a734e3d71452eb578aa8f92b5b6f99d83251e0b /src
parent32a53a48bc5349f8949a4e95446f80bbb0fcb9e3 (diff)
downloadSkyblocker-cd29a1475253ff3ca8098765875a45fdbefd75e7.tar.gz
Skyblocker-cd29a1475253ff3ca8098765875a45fdbefd75e7.tar.bz2
Skyblocker-cd29a1475253ff3ca8098765875a45fdbefd75e7.zip
Garden fixes (#1271)
* fixes #1270 * Update GardenPlotsWidget.java make garden plot widget clickable again. Cat did an oopsy * Update InventoryScreenMixin.java disable status overlay if garden plot widget is active * garden visitor changes for ironman players: you can change the coins/h calc to get the value from only npc added new option copy and open bazar for visitor (default true) also added visual clue if copied or not. made mos stuff translate able * Refactor visitor helper and farming hud translations --------- Co-authored-by: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java127
-rw-r--r--src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java63
-rw-r--r--src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java12
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java73
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java9
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/garden/visitor/VisitorHelper.java78
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java19
-rw-r--r--src/main/resources/assets/skyblocker/lang/en_us.json15
8 files changed, 262 insertions, 134 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java
index 9b90c096..5e0d7cd4 100644
--- a/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java
+++ b/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java
@@ -2,6 +2,7 @@ package de.hysky.skyblocker.config.categories;
import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
+import de.hysky.skyblocker.config.configs.FarmingConfig;
import de.hysky.skyblocker.skyblock.garden.FarmingHudWidget;
import de.hysky.skyblocker.skyblock.tabhud.config.WidgetsConfigurationScreen;
import de.hysky.skyblocker.utils.Location;
@@ -11,33 +12,41 @@ import net.minecraft.text.Text;
public class FarmingCategory {
- public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) {
- return ConfigCategory.createBuilder()
- .name(Text.translatable("skyblocker.config.farming"))
+ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) {
+ return ConfigCategory.createBuilder()
+ .name(Text.translatable("skyblocker.config.farming"))
- //Garden
- .group(OptionGroup.createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden"))
- .collapsed(false)
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.enableHud"))
- .binding(defaults.farming.garden.farmingHud.enableHud,
- () -> config.farming.garden.farmingHud.enableHud,
- newValue -> config.farming.garden.farmingHud.enableHud = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
- .option(ButtonOption.createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.farmingHud"))
- .text(Text.translatable("text.skyblocker.open"))
- .action((screen, opt) -> MinecraftClient.getInstance().setScreen(new WidgetsConfigurationScreen(Location.GARDEN, FarmingHudWidget.getInstance().getInternalID(), screen)))
- .build())
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.dicerTitlePrevent"))
- .binding(defaults.farming.garden.dicerTitlePrevent,
- () -> config.farming.garden.dicerTitlePrevent,
- newValue -> config.farming.garden.dicerTitlePrevent = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
+ //Garden
+ .group(OptionGroup.createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden"))
+ .collapsed(false)
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.enableHud"))
+ .binding(defaults.farming.garden.farmingHud.enableHud,
+ () -> config.farming.garden.farmingHud.enableHud,
+ newValue -> config.farming.garden.farmingHud.enableHud = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(ButtonOption.createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.farmingHud"))
+ .text(Text.translatable("text.skyblocker.open"))
+ .action((screen, opt) -> MinecraftClient.getInstance().setScreen(new WidgetsConfigurationScreen(Location.GARDEN, FarmingHudWidget.getInstance().getInternalID(), screen)))
+ .build())
+ .option(Option.<FarmingConfig.Type>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.farmingHud.type"))
+ .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.farmingHud.type.@Tooltip")))
+ .binding(defaults.farming.garden.farmingHud.type,
+ () -> config.farming.garden.farmingHud.type,
+ newValue -> config.farming.garden.farmingHud.type = newValue)
+ .controller(ConfigUtils::createEnumCyclingListController)
+ .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.dicerTitlePrevent"))
+ .binding(defaults.farming.garden.dicerTitlePrevent,
+ () -> config.farming.garden.dicerTitlePrevent,
+ newValue -> config.farming.garden.dicerTitlePrevent = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.farming.garden.pestHighlighter"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.pestHighlighter.@Tooltip")))
@@ -46,37 +55,37 @@ public class FarmingCategory {
newValue -> config.farming.garden.pestHighlighter = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.lockMouseTool"))
- .binding(defaults.farming.garden.lockMouseTool,
- () -> config.farming.garden.lockMouseTool,
- newValue -> config.farming.garden.lockMouseTool = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.lockMouseGround"))
- .binding(defaults.farming.garden.lockMouseGroundOnly,
- () -> config.farming.garden.lockMouseGroundOnly,
- newValue -> config.farming.garden.lockMouseGroundOnly = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.gardenPlotsWidget"))
- .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip")))
- .binding(defaults.farming.garden.gardenPlotsWidget,
- () -> config.farming.garden.gardenPlotsWidget,
- newValue -> config.farming.garden.gardenPlotsWidget = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
- .option(Option.<Boolean>createBuilder()
- .name(Text.translatable("skyblocker.config.farming.garden.closeScreenOnPlotClick"))
- .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.closeScreenOnPlotClick.@Tooltip")))
- .binding(defaults.farming.garden.closeScreenOnPlotClick,
- () -> config.farming.garden.closeScreenOnPlotClick,
- newValue -> config.farming.garden.closeScreenOnPlotClick = newValue)
- .controller(ConfigUtils::createBooleanController)
- .build())
- .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.lockMouseTool"))
+ .binding(defaults.farming.garden.lockMouseTool,
+ () -> config.farming.garden.lockMouseTool,
+ newValue -> config.farming.garden.lockMouseTool = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.lockMouseGround"))
+ .binding(defaults.farming.garden.lockMouseGroundOnly,
+ () -> config.farming.garden.lockMouseGroundOnly,
+ newValue -> config.farming.garden.lockMouseGroundOnly = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.gardenPlotsWidget"))
+ .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip")))
+ .binding(defaults.farming.garden.gardenPlotsWidget,
+ () -> config.farming.garden.gardenPlotsWidget,
+ newValue -> config.farming.garden.gardenPlotsWidget = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .option(Option.<Boolean>createBuilder()
+ .name(Text.translatable("skyblocker.config.farming.garden.closeScreenOnPlotClick"))
+ .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.closeScreenOnPlotClick.@Tooltip")))
+ .binding(defaults.farming.garden.closeScreenOnPlotClick,
+ () -> config.farming.garden.closeScreenOnPlotClick,
+ newValue -> config.farming.garden.closeScreenOnPlotClick = newValue)
+ .controller(ConfigUtils::createBooleanController)
+ .build())
+ .build())
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.farming.visitorHelper"))
.collapsed(false)
@@ -105,7 +114,7 @@ public class FarmingCategory {
.controller(ConfigUtils::createBooleanController)
.build())
.build())
- .build();
+ .build();
- }
+ }
}
diff --git a/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java
index 88506bfe..abb24fc6 100644
--- a/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java
+++ b/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java
@@ -1,37 +1,38 @@
package de.hysky.skyblocker.config.configs;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
+import net.minecraft.client.resource.language.I18n;
public class FarmingConfig {
- @SerialEntry
- public Garden garden = new Garden();
+ @SerialEntry
+ public Garden garden = new Garden();
@SerialEntry
public VisitorHelper visitorHelper = new VisitorHelper();
- public static class Garden {
- @SerialEntry
- public FarmingHud farmingHud = new FarmingHud();
+ public static class Garden {
+ @SerialEntry
+ public FarmingHud farmingHud = new FarmingHud();
- @SerialEntry
- public boolean dicerTitlePrevent = true;
+ @SerialEntry
+ public boolean dicerTitlePrevent = true;
@SerialEntry
public boolean pestHighlighter = true;
- @SerialEntry
- public boolean lockMouseTool = false;
+ @SerialEntry
+ public boolean lockMouseTool = false;
- @SerialEntry
- public boolean lockMouseGroundOnly = false;
+ @SerialEntry
+ public boolean lockMouseGroundOnly = false;
- @SerialEntry
- public boolean gardenPlotsWidget = true;
+ @SerialEntry
+ public boolean gardenPlotsWidget = true;
- @SerialEntry
- public boolean closeScreenOnPlotClick = false;
- }
+ @SerialEntry
+ public boolean closeScreenOnPlotClick = false;
+ }
public static class VisitorHelper {
@SerialEntry
@@ -44,14 +45,28 @@ public class FarmingConfig {
public boolean showStacksInVisitorHelper = false;
}
- public static class FarmingHud {
- @SerialEntry
- public boolean enableHud = true;
+ public static class FarmingHud {
+ @SerialEntry
+ public boolean enableHud = true;
- @SerialEntry
- public int x;
+ @SerialEntry
+ public int x;
+
+ @SerialEntry
+ public int y;
+
+ @SerialEntry
+ public Type type = Type.BOTH;
+ }
- @SerialEntry
- public int y;
- }
+ public enum Type {
+ BOTH,
+ NPC,
+ BAZAAR;
+
+ @Override
+ public String toString() {
+ return I18n.translate("skyblocker.config.farming.garden.farmingHud.type." + name());
+ }
+ }
}
diff --git a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java
index b7455c2e..7d85500c 100644
--- a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java
+++ b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java
@@ -51,13 +51,19 @@ public abstract class InventoryScreenMixin extends HandledScreen<PlayerScreenHan
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/StatusEffectsDisplay;drawStatusEffects(Lnet/minecraft/client/gui/DrawContext;IIF)V"))
private boolean skyblocker$dontDrawStatusEffects(StatusEffectsDisplay statusEffectsDisplay, DrawContext context, int mouseX, int mouseY, float tickDelta) {
- return !(Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.hideStatusEffectOverlay);
+ return !(Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.hideStatusEffectOverlay || Utils.isInGarden() && SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget);
}
- //This makes it so that REI at least doesn't wrongly exclude the zone
+ // This makes it so that REI at least doesn't wrongly exclude the zone
+ // shouldHideStatusEffectHud should actually be showsStatusEffects
@ModifyReturnValue(method = "shouldHideStatusEffectHud", at = @At("RETURN"))
private boolean skyblocker$markStatusEffectsHidden(boolean original) {
- return Utils.isOnSkyblock() ? !SkyblockerConfigManager.get().uiAndVisuals.hideStatusEffectOverlay : original;
+ // In the garden, status effects are shown when both hideStatusEffectOverlay and gardenPlotsWidget are false
+ if (Utils.isInGarden()) return original && !SkyblockerConfigManager.get().uiAndVisuals.hideStatusEffectOverlay && !SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget;
+ // In the rest of Skyblock, status effects are shown when hideStatusEffectOverlay is false
+ if (Utils.isOnSkyblock()) return original && !SkyblockerConfigManager.get().uiAndVisuals.hideStatusEffectOverlay;
+ // In vanilla, status effects are shown as normal
+ return original;
}
@Inject(method = "onRecipeBookToggled", at = @At("TAIL"))
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java
index bfa76c2a..532ba879 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java
@@ -92,18 +92,18 @@ public class FarmingHudWidget extends ComponentBasedWidget {
if (FarmingHud.CounterType.NONE.matchesText(counterText)) counterNumber = "";
addSimpleIcoText(cropStack, counterText, Formatting.YELLOW, counterNumber);
float cropsPerMinute = FarmingHud.cropsPerMinute();
- addSimpleIcoText(cropStack, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) cropsPerMinute / 10 * 10));
- addSimpleIcoText(Ico.GOLD, "Coins/h: ", Formatting.GOLD, getPriceText(cropItemId, cropsPerMinute));
- addSimpleIcoText(cropStack, "Blocks/s: ", Formatting.YELLOW, Double.toString(FarmingHud.blockBreaks()));
+ addSimpleIconTranslatableText(cropStack, "skyblocker.config.farming.general.cropsPerMin", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) cropsPerMinute / 10 * 10));
+ addSimpleIconTranslatableText(Ico.GOLD, "skyblocker.config.farming.general.coinsPerHour", Formatting.GOLD, getPriceText(cropItemId, cropsPerMinute));
+ addSimpleIconTranslatableText(cropStack, "skyblocker.config.farming.general.blocksPerSec", Formatting.YELLOW, Double.toString(FarmingHud.blockBreaks()));
//noinspection DataFlowIssue
- addComponent(Components.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(FarmingHud.farmingXpPerHour()));
+ addComponent(Components.progressComponent(Ico.LANTERN, Text.translatable("skyblocker.config.farming.general.farmingLevel"), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue()));
+ addSimpleIconTranslatableText(Ico.LIME_DYE, "skyblocker.config.farming.general.farmingXPPerHour", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format(FarmingHud.farmingXpPerHour()));
Entity cameraEntity = client.getCameraEntity();
- String yaw = cameraEntity == null ? "No Camera Entity" : String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getYaw()));
- String pitch = cameraEntity == null ? "No Camera Entity" : String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getPitch()));
- addComponent(new PlainTextComponent(Text.literal("Yaw: " + yaw).formatted(Formatting.GOLD)));
- addComponent(new PlainTextComponent(Text.literal("Pitch: " + pitch).formatted(Formatting.GOLD)));
+ Text yaw = cameraEntity == null ? Text.translatable("skyblocker.config.farming.general.noCameraEntity") : Text.literal(String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getYaw())));
+ Text pitch = cameraEntity == null ? Text.translatable("skyblocker.config.farming.general.noCameraEntity") : Text.literal(String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getPitch())));
+ addComponent(new PlainTextComponent(Text.translatable("skyblocker.config.farming.general.yaw", yaw).formatted(Formatting.GOLD)));
+ addComponent(new PlainTextComponent(Text.translatable("skyblocker.config.farming.general.pitch", pitch).formatted(Formatting.GOLD)));
if (LowerSensitivity.isSensitivityLowered()) {
addComponent(new PlainTextComponent(Text.translatable("skyblocker.garden.hud.mouseLocked").formatted(Formatting.ITALIC)));
}
@@ -111,16 +111,59 @@ public class FarmingHudWidget extends ComponentBasedWidget {
/**
* Gets the price text of the given crop id, calculated with the given crops per minute and the npc price if it's higher than the bazaar sell price, or the bazaar sell price otherwise.
+ * The used price depends on the config:
+ * - BAZAAR: only bazaar price (if available)
+ * - NPC: only npc price (if available)
+ * - BOTH: higher of NPC or bazaar price
*/
- private String getPriceText(String cropItemId, float cropsPerMinute) {
+ private Text getPriceText(String cropItemId, float cropsPerMinute) {
DoubleBooleanPair itemBazaarPrice = ItemUtils.getItemPrice(cropItemId); // Gets the bazaar sell price of the crop.
- double itemNpcPrice = TooltipInfoType.NPC.hasOrNullWarning(cropItemId) ? TooltipInfoType.NPC.getData().getDouble(cropItemId) : Double.MIN_VALUE; // Gets the npc sell price of the crop or set to the min double value if it doesn't exist.
- boolean shouldUseNpcPrice = itemNpcPrice > itemBazaarPrice.leftDouble(); // Use the npc price if it's more than the bazaar sell price.
- double price = shouldUseNpcPrice ? itemNpcPrice : itemBazaarPrice.leftDouble(); // same as above
+ double bazaarPrice = itemBazaarPrice.leftDouble();
+ boolean hasBazaarData = itemBazaarPrice.rightBoolean();
+
+ // Gets the npc sell price of the crop or set to the min double value if it doesn't exist.
+ double itemNpcPrice = TooltipInfoType.NPC.hasOrNullWarning(cropItemId) ? TooltipInfoType.NPC.getData().getDouble(cropItemId) : Double.MIN_VALUE;
+
+ double priceToUse = 0;
+ Text sourceLabel = null;
+ boolean hasValidPrice = false;
+
+ switch (SkyblockerConfigManager.get().farming.garden.farmingHud.type) {
+ case NPC -> {
+ // Use NPC price if it's available.
+ if (itemNpcPrice > 0 && itemNpcPrice != Double.MIN_VALUE) {
+ priceToUse = itemNpcPrice;
+ sourceLabel = Text.literal(" (").append(Text.translatable("skyblocker.config.farming.garden.farmingHud.type.NPC")).append(")");
+ hasValidPrice = true;
+ }
+ }
+ case BAZAAR -> {
+ // Use Bazaar price if data is available.
+ if (hasBazaarData) {
+ priceToUse = bazaarPrice;
+ sourceLabel = Text.literal(" (").append(Text.translatable("skyblocker.config.farming.garden.farmingHud.type.BAZAAR")).append(")");
+ hasValidPrice = true;
+ }
+ }
+ case BOTH -> {
+ // Use the NPC price if it's higher than the Bazaar price and available.
+ if (itemNpcPrice > bazaarPrice && itemNpcPrice != Double.MIN_VALUE) {
+ priceToUse = itemNpcPrice;
+ sourceLabel = Text.literal(" (").append(Text.translatable("skyblocker.config.farming.garden.farmingHud.type.NPC")).append(")");
+ hasValidPrice = true;
+ }
+ // Otherwise, use Bazaar price if available.
+ else if (hasBazaarData) {
+ priceToUse = bazaarPrice;
+ sourceLabel = Text.literal(" (").append(Text.translatable("skyblocker.config.farming.garden.farmingHud.type.BAZAAR")).append(")");
+ hasValidPrice = true;
+ }
+ }
+ }
+
- // Return the formatted price if npc price is higher or bazaar price is present.
// Multiply by 60 to convert to hourly and divide by 100 for rounding is combined into multiplying by 0.6.
- return shouldUseNpcPrice || itemBazaarPrice.rightBoolean() ? FarmingHud.NUMBER_FORMAT.format((int) (price * cropsPerMinute * 0.6) * 100) : "No Data";
+ return hasValidPrice ? Text.literal(FarmingHud.NUMBER_FORMAT.format((int) (priceToUse * cropsPerMinute * 0.6) * 100)).append(sourceLabel) : Text.translatable("skyblocker.config.farming.general.noData");
}
@Override
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java
index 7d2c22b3..b0db4b81 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java
@@ -374,6 +374,15 @@ public class GardenPlotsWidget extends ContainerWidget {
}
}
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ if (isMouseOver(mouseX, mouseY) && isValidClickButton(button)) {
+ onClick(mouseX, mouseY);
+ return true;
+ }
+ return super.mouseClicked(mouseX, mouseY, button);
+ }
+
private record GardenPlot(Item item, String name) {
}
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/visitor/VisitorHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/visitor/VisitorHelper.java
index 7b36907e..1ffdf448 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/garden/visitor/VisitorHelper.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/visitor/VisitorHelper.java
@@ -3,11 +3,17 @@ package de.hysky.skyblocker.skyblock.garden.visitor;
import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
-import de.hysky.skyblocker.utils.*;
+import de.hysky.skyblocker.utils.Formatters;
+import de.hysky.skyblocker.utils.ItemUtils;
+import de.hysky.skyblocker.utils.NEURepoManager;
+import de.hysky.skyblocker.utils.Utils;
+import de.hysky.skyblocker.utils.render.RenderHelper;
import de.hysky.skyblocker.utils.scheduler.MessageScheduler;
import io.github.moulberry.repo.data.NEUItem;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Object2LongMap;
+import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
@@ -19,7 +25,6 @@ import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.MutableText;
-import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -36,6 +41,7 @@ public class VisitorHelper {
private static final int ICON_SIZE = 16;
private static final int LINE_HEIGHT = 3;
private static final ItemStack BARRIER = new ItemStack(Items.BARRIER);
+ private static final Object2LongMap<Text> copiedTimestamps = new Object2LongOpenHashMap<>();
// Used to prevent adding the visitor again after the player clicks accept or refuse.
private static boolean processVisitor = false;
@@ -179,17 +185,23 @@ public class VisitorHelper {
}
MutableText name = cachedStack != null ? cachedStack.getName().copy() : itemName.copy();
- Text itemText = SkyblockerConfigManager.get().farming.visitorHelper.showStacksInVisitorHelper && totalAmount >= 64
- ? name
- .append(" x" + (totalAmount / 64) + " stacks + " + (totalAmount % 64))
- : name
- .append(" x" + totalAmount);
-
- int itemTextWidth = textRenderer.getWidth(itemText);
- int copyTextX = textX + itemTextWidth;
+ MutableText itemText = SkyblockerConfigManager.get().farming.visitorHelper.showStacksInVisitorHelper && totalAmount >= 64
+ ? name.append(" x" + (totalAmount / 64) + " stacks + " + (totalAmount % 64))
+ : name.append(" x" + totalAmount);
+
+ double mouseX = MinecraftClient.getInstance().mouse.getX() / MinecraftClient.getInstance().getWindow().getScaleFactor();
+ double mouseY = MinecraftClient.getInstance().mouse.getY() / MinecraftClient.getInstance().getWindow().getScaleFactor();
+
+ if (copiedTimestamps.containsKey(itemName)) {
+ long timeSinceCopy = System.currentTimeMillis() - copiedTimestamps.getLong(itemName);
+ if (timeSinceCopy < 1000) {
+ itemText.append(Text.literal(" ✔ ").formatted(Formatting.GREEN));
+ } else {
+ copiedTimestamps.removeLong(itemName);
+ }
+ }
- context.drawText(textRenderer, itemText, textX, yPosition, -1, true);
- context.drawText(textRenderer, Text.literal(" [Copy Amount]").setStyle(Style.EMPTY.withColor(Formatting.YELLOW)), copyTextX, yPosition, -1, true);
+ drawTextWithHoverUnderline(context, textRenderer, itemText, textX, yPosition, mouseX, mouseY);
index++;
}
@@ -197,7 +209,6 @@ public class VisitorHelper {
context.getMatrices().pop();
}
-
/**
* Handles mouse click events on the visitor UI.
*/
@@ -205,7 +216,6 @@ public class VisitorHelper {
if (mouseButton != 0) return;
int index = 0;
- int yOffsetAdjustment = -5;
for (Object2IntMap.Entry<Text> entry : groupedItems.object2IntEntrySet()) {
Text itemName = entry.getKey();
@@ -219,29 +229,19 @@ public class VisitorHelper {
int iconX = X_OFFSET + 12;
int textX = iconX + (int) (ICON_SIZE * 0.95f) + 4;
- int yPosition = Y_OFFSET + index * (LINE_HEIGHT + textRenderer.fontHeight) -
- (int) ((float) textRenderer.fontHeight / 2 - ICON_SIZE * 0.95f / 2) + yOffsetAdjustment;
+ int yPosition = Y_OFFSET + index * (LINE_HEIGHT + textRenderer.fontHeight);
+ MutableText name = itemName.copy();
Text itemText = SkyblockerConfigManager.get().farming.visitorHelper.showStacksInVisitorHelper && totalAmount >= 64
- ? itemName.copy()
- .append(" x" + (totalAmount / 64) + " stacks + " + (totalAmount % 64))
- : itemName.copy()
- .append(" x" + totalAmount);
+ ? name.append(" x" + (totalAmount / 64) + " stacks + " + (totalAmount % 64))
+ : name.append(" x" + totalAmount);
- int itemTextWidth = textRenderer.getWidth(itemText);
- int copyTextX = textX + itemTextWidth;
+ if (isMouseOverText(textRenderer, itemText, textX, yPosition, mouseX, mouseY)) {
+ MinecraftClient.getInstance().keyboard.setClipboard(String.valueOf(totalAmount));
+ copiedTimestamps.put(itemName, System.currentTimeMillis());
- if (isMouseOverText(mouseX, mouseY, textX, yPosition, itemTextWidth, textRenderer.fontHeight)) {
MessageScheduler.INSTANCE.sendMessageAfterCooldown("/bz " + itemName.getString(), true);
- return;
- }
- if (isMouseOverText(mouseX, mouseY, copyTextX, yPosition, textRenderer.getWidth(" [Copy Amount]"), textRenderer.fontHeight)) {
- MinecraftClient client = MinecraftClient.getInstance();
- client.keyboard.setClipboard(String.valueOf(totalAmount));
- if (client.player != null) {
- client.player.sendMessage(Constants.PREFIX.get().append("Copied amount successfully"), false);
- }
return;
}
@@ -265,10 +265,22 @@ public class VisitorHelper {
updateItems();
}
+ private static void drawTextWithHoverUnderline(DrawContext context, TextRenderer textRenderer, Text text, int x, int y, double mouseX, double mouseY) {
+ context.getMatrices().push();
+ context.getMatrices().translate(0, 0, 500);
+ context.drawText(textRenderer, text, x, y, -1, true);
+
+ if (isMouseOverText(textRenderer, text, x, y, mouseX, mouseY)) {
+ context.drawHorizontalLine(x, x + textRenderer.getWidth(text), y + textRenderer.fontHeight, -1);
+ }
+
+ context.getMatrices().pop();
+ }
+
/**
* Checks if the mouse is over a specific rectangular region.
*/
- private static boolean isMouseOverText(double mouseX, double mouseY, int x, int y, int width, int height) {
- return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
+ private static boolean isMouseOverText(TextRenderer textRenderer, Text text, int x, int y, double mouseX, double mouseY) {
+ return RenderHelper.pointIsInArea(mouseX, mouseY, x, y, x + textRenderer.getWidth(text), y + textRenderer.fontHeight);
}
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java
index eb709f1e..2095cc4a 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComponentBasedWidget.java
@@ -1,5 +1,6 @@
package de.hysky.skyblocker.skyblock.tabhud.widget;
+import com.demonwav.mcdev.annotations.Translatable;
import com.mojang.logging.LogUtils;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder;
@@ -100,6 +101,16 @@ public abstract class ComponentBasedWidget extends HudWidget {
this.addComponent(Components.iconTextComponent(ico, txt));
}
+ public final void addSimpleIconTranslatableText(ItemStack icon, @Translatable String translationKey, Formatting formatting, String content) {
+ Text text = simpleEntryTranslatableText(translationKey, content, formatting);
+ this.addComponent(new IcoTextComponent(icon, text));
+ }
+
+ public final void addSimpleIconTranslatableText(ItemStack icon, @Translatable String translationKey, Formatting formatting, Text content) {
+ Text text = simpleEntryTranslatableText(translationKey, content, formatting);
+ this.addComponent(new IcoTextComponent(icon, text));
+ }
+
@Override
public final void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
MatrixStack ms = context.getMatrices();
@@ -203,6 +214,14 @@ public abstract class ComponentBasedWidget extends HudWidget {
return Text.literal(entryName).append(Text.literal(entryContent).formatted(contentFmt));
}
+ public static Text simpleEntryTranslatableText(String translationKey, String content, Formatting contentFormatting) {
+ return Text.translatable(translationKey, Text.literal(content).formatted(contentFormatting));
+ }
+
+ public static Text simpleEntryTranslatableText(String translationKey, Text content, Formatting contentFormatting) {
+ return Text.translatable(translationKey, content.copy().formatted(contentFormatting));
+ }
+
/**
* @return the entry at idx as unformatted Text
*/
diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json
index 8a067076..dbb3db8e 100644
--- a/src/main/resources/assets/skyblocker/lang/en_us.json
+++ b/src/main/resources/assets/skyblocker/lang/en_us.json
@@ -242,6 +242,11 @@
"skyblocker.config.farming.garden.dicerTitlePrevent": "Enable Dicer Title Prevent",
"skyblocker.config.farming.garden.enableHud": "Enable Farming HUD",
"skyblocker.config.farming.garden.farmingHud": "Farming HUD Config...",
+ "skyblocker.config.farming.garden.farmingHud.type": "Use Price Value From",
+ "skyblocker.config.farming.garden.farmingHud.type.@Tooltip": "Which price to use when calculating coins in the farming HUD.\n'Both' uses whichever price is higher.",
+ "skyblocker.config.farming.garden.farmingHud.type.NPC": "NPC",
+ "skyblocker.config.farming.garden.farmingHud.type.BAZAAR": "Bazaar",
+ "skyblocker.config.farming.garden.farmingHud.type.BOTH": "Both",
"skyblocker.config.farming.garden.gardenPlotsWidget": "Enable Garden Plots Widget",
"skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip": "While in the garden, on the right of your inventory there will be a widget to quickly teleport to plots. It will also show plots that have pests (this requires the Pests widget to be enabled and visible in the Tab).",
"skyblocker.config.farming.garden.lockMouseGround": "Only lock camera when on the ground",
@@ -257,6 +262,16 @@
"skyblocker.config.farming.visitorHelper.showStacksInVisitorHelper": "Show Stacks in Visitor Helper",
"skyblocker.config.farming.visitorHelper.showStacksInVisitorHelper.@Tooltip": "Show's the required items as (5 stacks + 45) rather than just a total number especially useful for ironman players.",
+ "skyblocker.config.farming.general.cropsPerMin": "Crops/min: %s",
+ "skyblocker.config.farming.general.coinsPerHour": "Coins/h: %s",
+ "skyblocker.config.farming.general.blocksPerSec": "Blocks/s: %s",
+ "skyblocker.config.farming.general.farmingLevel": "Farming Level:",
+ "skyblocker.config.farming.general.farmingXPPerHour": "Farming XP/h: %s",
+ "skyblocker.config.farming.general.noCameraEntity": "No Camera Entity",
+ "skyblocker.config.farming.general.yaw": "Yaw: %s",
+ "skyblocker.config.farming.general.pitch": "Pitch: %s",
+ "skyblocker.config.farming.general.noData": "No Data",
+
"skyblocker.config.foraging": "Foraging",
"skyblocker.config.foraging.galatea": "Galatea",
"skyblocker.config.foraging.galatea.enableForestNodeHelper": "Enable Forest Node Helper",