1414import it .unimi .dsi .fastutil .longs .LongLongPair ;
1515import it .unimi .dsi .fastutil .longs .LongPriorityQueue ;
1616import net .fabricmc .fabric .api .client .command .v2 .ClientCommandRegistrationCallback ;
17+ import net .fabricmc .fabric .api .client .event .lifecycle .v1 .ClientTickEvents ;
1718import 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 ;
2019import net .fabricmc .fabric .api .event .client .player .ClientPlayerBlockBreakEvents ;
2120import net .minecraft .ChatFormatting ;
2221import net .minecraft .client .Minecraft ;
2322import net .minecraft .nbt .CompoundTag ;
2423import net .minecraft .nbt .NumericTag ;
25- import net .minecraft .resources .Identifier ;
2624import net .minecraft .world .item .ItemStack ;
2725import net .minecraft .world .level .block .Blocks ;
2826import org .slf4j .Logger ;
4139
4240public 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 ;
0 commit comments