Skip to content

Commit c836b28

Browse files
committed
Minor Farming Hud Fixes (#2223)
(cherry picked from commit f512865)
1 parent 68196ba commit c836b28

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
import it.unimi.dsi.fastutil.longs.LongLongPair;
1515
import it.unimi.dsi.fastutil.longs.LongPriorityQueue;
1616
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
17+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
1718
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
18-
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
19-
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
2019
import net.fabricmc.fabric.api.event.client.player.ClientPlayerBlockBreakEvents;
2120
import net.minecraft.ChatFormatting;
2221
import net.minecraft.client.Minecraft;
2322
import net.minecraft.nbt.CompoundTag;
2423
import net.minecraft.nbt.NumericTag;
25-
import net.minecraft.resources.Identifier;
2624
import net.minecraft.world.item.ItemStack;
2725
import net.minecraft.world.level.block.Blocks;
2826
import org.slf4j.Logger;
@@ -41,7 +39,6 @@
4139

4240
public class FarmingHud {
4341
private static final Logger LOGGER = LoggerFactory.getLogger(FarmingHud.class);
44-
private static final Identifier FARMING_HUD = SkyblockerMod.id("farming_hud");
4542
public static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);
4643
private static final Pattern FARMING_XP = Pattern.compile("\\+(?<xp>\\d+(?:\\.\\d+)?) Farming \\((?<percent>[\\d,]+(?:\\.\\d+)?%|[\\d,]+/[\\d,]+)\\)");
4744
private static final Minecraft client = Minecraft.getInstance();
@@ -56,7 +53,7 @@ public class FarmingHud {
5653

5754
@Init
5855
public static void init() {
59-
HudElementRegistry.attachElementAfter(VanillaHudElements.STATUS_EFFECTS, FARMING_HUD, (context, tickCounter) -> {
56+
ClientTickEvents.END_CLIENT_TICK.register(_minecraft -> {
6057
if (shouldRender()) {
6158
if (!counter.isEmpty() && counter.peek().rightLong() + STATS_WINDOW < System.currentTimeMillis()) {
6259
counter.poll();
@@ -88,7 +85,7 @@ public static void init() {
8885
if (!newState.isAir() || !oldState.is(Blocks.CACTUS)) return; // Cactus was replaced with air
8986
if (!client.level.getBlockState(pos.below()).is(Blocks.CACTUS)) return; // Don't count any blocks above one that was broken.
9087
if (client.player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > 64) return; // check if within 8 blocks of the player
91-
if (!client.player.getMainHandItem().getNeuName().equals("CACTUS_KNIFE")) return;
88+
if (!client.player.getMainHandItem().getNeuName().startsWith("CACTUS_KNIFE")) return;
9289
blockBreaks.enqueue(System.currentTimeMillis());
9390
});
9491

@@ -111,6 +108,7 @@ public static void init() {
111108
.executes(Scheduler.queueOpenScreenCommand(() -> new WidgetsConfigurationScreen(Location.GARDEN, "hud_garden", null)))))));
112109
}
113110

111+
@SuppressWarnings("SameParameterValue")
114112
private static boolean tryGetCounter(ItemStack stack, CounterType counterType) {
115113
CompoundTag customData = ItemUtils.getCustomData(stack);
116114
if (customData.isEmpty() || !(customData.get(counterType.nbtKey) instanceof NumericTag)) return true;

src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public WidgetsConfigurationScreen(ChestMenu handler, String titleLowercase) {
150150
* @param targetLocation open the preview to this location
151151
* @param widgetLayerToGoTo go to this widget's layer
152152
*/
153-
public WidgetsConfigurationScreen(Location targetLocation, String widgetLayerToGoTo, Screen parent) {
153+
public WidgetsConfigurationScreen(Location targetLocation, String widgetLayerToGoTo, @Nullable Screen parent) {
154154
this(null, "", targetLocation, WidgetManager.getScreenBuilder(targetLocation).getPositionRuleOrDefault(widgetLayerToGoTo).screenLayer());
155155
this.parent = parent;
156156
}

0 commit comments

Comments
 (0)