From 337b77aa50db6b4a159795827623d36acccbdcc4 Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Fri, 9 Dec 2022 13:19:54 +0100 Subject: Katting (#447) Co-authored-by: nea Co-authored-by: nea Co-authored-by: nea Co-authored-by: nea Co-authored-by: nea Co-authored-by: nea Co-authored-by: nea --- .../moulberry/notenoughupdates/util/ItemUtils.java | 30 +++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java index 3e2dd465..2ff9692d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java @@ -189,6 +189,16 @@ public class ItemUtils { } public static ItemStack createPetItemstackFromPetInfo(PetInfoOverlay.Pet currentPet) { + if (currentPet == null) { + ItemStack stack = ItemUtils.createQuestionMarkSkull(EnumChatFormatting.RED + "Unknown Pet"); + appendLore(stack, Arrays.asList( + "§cNull Pet", + "", + "§cIf you expected it to be there please send a message in", + "§c§l#neu-support §r§con §ldiscord.gg/moulberry" + )); + return stack; + } String petname = currentPet.petType; String tier = Utils.getRarityFromInt(currentPet.rarity.petId).toUpperCase(); String heldItem = currentPet.petItem; @@ -196,11 +206,13 @@ public class ItemUtils { JsonObject heldItemJson = heldItem == null ? null : NotEnoughUpdates.INSTANCE.manager.getItemInformation().get( heldItem); String petId = currentPet.getPetId(false); - float exp = currentPet.petLevel.totalXp; + float exp = currentPet.petLevel.getExpTotal(); - GuiProfileViewer.PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp); + PetLeveling.PetLevel levelObj = PetLeveling + .getPetLevelingForPet(petname, PetInfoOverlay.Rarity.valueOf(tier)) + .getPetLevel(exp); - float level = levelObj.level; + int level = levelObj.getCurrentLevel(); ItemStack petItemstack = NotEnoughUpdates.INSTANCE.manager .createItemResolutionQuery() @@ -348,7 +360,7 @@ public class ItemUtils { if (Utils.cleanColour(lore.getStringTagAt(0)).matches(ItemTooltipListener.petToolTipRegex) && lore.tagCount() > 7) { - GuiProfileViewer.PetLevel petLevel; + PetLeveling.PetLevel petLevel; PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack( stack.getTagCompound() @@ -373,13 +385,13 @@ public class ItemUtils { for (int i = 0; i < lore.tagCount(); i++) { if (i == lore.tagCount() - 2) { newLore.appendTag(new NBTTagString("")); - if (petLevel.level >= maxLvl) { + if (petLevel.getCurrentLevel() >= maxLvl) { newLore.appendTag(new NBTTagString( EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "MAX LEVEL")); } else { - double levelPercent = (Math.round(petLevel.levelPercentage * 1000) / 10.0); + double levelPercent = (Math.round(petLevel.getPercentageToNextLevel() * 1000) / 10.0); newLore.appendTag(new NBTTagString( - EnumChatFormatting.GRAY + "Progress to Level " + (int) (petLevel.level + 1) + ": " + + EnumChatFormatting.GRAY + "Progress to Level " + (petLevel.getCurrentLevel() + 1) + ": " + EnumChatFormatting.YELLOW + levelPercent + "%")); StringBuilder sb = new StringBuilder(); @@ -394,9 +406,9 @@ public class ItemUtils { newLore.appendTag(new NBTTagString(sb.toString())); newLore.appendTag(new NBTTagString( EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + - decimalFormatter.format(petLevel.levelXp) + + decimalFormatter.format(petLevel.getExpInCurrentLevel()) + EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + - decimalFormatter.format(petLevel.currentLevelRequirement) + decimalFormatter.format(petLevel.getExpRequiredForNextLevel()) )); } } -- cgit