diff options
| author | viciscat <51047087+viciscat@users.noreply.github.com> | 2025-07-24 21:19:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-24 15:19:08 -0400 |
| commit | c9ddb1bc0a23cf8dea4bb4af216b39a3323a1ceb (patch) | |
| tree | c392a25ff43c25480d18a53e1d49af24cdd17dfe /src/main/java | |
| parent | b7b7e74ee085b3c750e7bec6999c54535e6267f9 (diff) | |
| download | Skyblocker-c9ddb1bc0a23cf8dea4bb4af216b39a3323a1ceb.tar.gz Skyblocker-c9ddb1bc0a23cf8dea4bb4af216b39a3323a1ceb.tar.bz2 Skyblocker-c9ddb1bc0a23cf8dea4bb4af216b39a3323a1ceb.zip | |
use longs to prevent overflow (#1527)
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java | 20 |
1 files changed, 10 insertions, 10 deletions
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 3d831f66..d5946166 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHud.java @@ -9,8 +9,8 @@ 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.LongLongPair; 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; @@ -44,7 +44,7 @@ public class FarmingHud { private static final Pattern FARMING_XP = Pattern.compile("\\+(?<xp>\\d+(?:\\.\\d+)?) Farming \\((?<percent>[\\d,]+(?:\\.\\d+)?%|[\\d,]+/[\\d,]+)\\)"); private static final MinecraftClient client = MinecraftClient.getInstance(); private static CounterType counterType = CounterType.NONE; - private static final Deque<IntLongPair> counter = new ArrayDeque<>(); + private static final Deque<LongLongPair> counter = new ArrayDeque<>(); private static final LongPriorityQueue blockBreaks = new LongArrayFIFOQueue(); private static final Queue<FloatLongPair> farmingXp = new ArrayDeque<>(); private static float farmingXpPercentProgress; @@ -97,13 +97,13 @@ public class FarmingHud { private static boolean tryGetCounter(ItemStack stack, CounterType counterType) { NbtCompound customData = ItemUtils.getCustomData(stack); if (customData.isEmpty() || !(customData.get(counterType.nbtKey) instanceof AbstractNbtNumber)) return true; - int count = customData.getInt(counterType.nbtKey, 0); + long count = customData.getLong(counterType.nbtKey, 0); if (FarmingHud.counterType != counterType) { counter.clear(); FarmingHud.counterType = counterType; } - if (counter.isEmpty() || counter.peekLast().leftInt() != count) { - counter.offer(IntLongPair.of(count, System.currentTimeMillis())); + if (counter.isEmpty() || counter.peekLast().leftLong() != count) { + counter.offer(LongLongPair.of(count, System.currentTimeMillis())); } return false; } @@ -116,17 +116,17 @@ public class FarmingHud { return counterType.text; } - public static int counter() { - return counter.isEmpty() ? 0 : counter.peekLast().leftInt(); + public static long counter() { + return counter.isEmpty() ? 0 : counter.peekLast().leftLong(); } public static float cropsPerMinute() { if (counter.isEmpty()) { return 0; } - IntLongPair first = counter.peek(); - IntLongPair last = counter.peekLast(); - return (float) (last.leftInt() - first.leftInt()) / (last.rightLong() - first.rightLong()) * 60_000f; + LongLongPair first = counter.peek(); + LongLongPair last = counter.peekLast(); + return (float) (last.leftLong() - first.leftLong()) / (last.rightLong() - first.rightLong()) * 60_000f; } public static double blockBreaks() { |
