From fbdbde5ea7db57e41e4defd4377ec2d4773f315d Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 31 Dec 2022 14:06:45 +1100 Subject: fix current xp showing above max xp for level 100 (#515) --- .../moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 13179179..37cb14b5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -496,7 +496,7 @@ public class PetInfoOverlay extends TextOverlay { DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); if (pet == null) return 0; try { - return Float.parseFloat(df.format(pet.petLevel.getPercentageToNextLevel() * 100f)); + return Float.parseFloat(df.format(Math.min(pet.petLevel.getPercentageToNextLevel() * 100f, 100f))); } catch (Exception ignored) { return 0; } @@ -516,7 +516,8 @@ public class PetInfoOverlay extends TextOverlay { roundFloat(currentPet.petLevel.getExpRequiredForNextLevel()) + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)"; - String lvlString = EnumChatFormatting.AQUA + "" + Utils.shortNumberFormat(levelXp, 0) + "/" + + String lvlString = EnumChatFormatting.AQUA + "" + + Utils.shortNumberFormat(Math.min(levelXp, currentPet.petLevel.getExpRequiredForNextLevel()), 0) + "/" + Utils.shortNumberFormat(currentPet.petLevel.getExpRequiredForNextLevel(), 0) + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)"; -- cgit