diff options
author | Linnea Gräf <nea@nea.moe> | 2024-04-25 14:11:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 14:11:03 +0200 |
commit | 0f5e1486b43ba4164cc053d1b6456f00b9c38949 (patch) | |
tree | f560b59ce18a49b6cad2afdc1f0e786ecf0bfe72 | |
parent | faf22b5dd9d655f4f70beb7d1463025982ae734b (diff) | |
download | NotEnoughUpdates-0f5e1486b43ba4164cc053d1b6456f00b9c38949.tar.gz NotEnoughUpdates-0f5e1486b43ba4164cc053d1b6456f00b9c38949.tar.bz2 NotEnoughUpdates-0f5e1486b43ba4164cc053d1b6456f00b9c38949.zip |
Fix crash when loading montezuma with invalid pet id (#1113)
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java index 1a72d2e6..721ba23b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java @@ -54,6 +54,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.Collections; import java.util.List; +import java.util.ListIterator; public class RiftPage extends GuiProfileViewerPage { @@ -132,7 +133,7 @@ public class RiftPage extends GuiProfileViewerPage { int manaRegen = size * 2; APIDataJson.Rift.RiftDeadCats.Pet montezuma = deadCats.montezuma; - if (montezuma != null) { + if (montezuma != null && !"UNKNOWN".equals(montezuma.type)) { PetInfoOverlay.Pet pet = new PetInfoOverlay.Pet(); pet.petLevel = new PetLeveling.PetLevel(100, 100, 0, 0, 0, montezuma.exp); @@ -145,9 +146,17 @@ public class RiftPage extends GuiProfileViewerPage { if ((mouseX > guiLeft + 37 && mouseX < guiLeft + 37 + 20) && (mouseY > guiTop + 158 && mouseY < guiTop + 158 + 20)) { List<String> tooltip = petItemStackFromPetInfo.getTooltip(Minecraft.getMinecraft().thePlayer, false); - tooltip.set(3, "§7Found: §9" + size + "/9 Soul Pieces"); - tooltip.set(5, "§7Rift Time: §a+" + riftTime + "s"); - if (pet.rarity == PetInfoOverlay.Rarity.EPIC) tooltip.set(6, "§7Mana Regen: §a+" + manaRegen + "%"); + ListIterator<String> iterator = tooltip.listIterator(); + while (iterator.hasNext()) { + String next = iterator.next(); + if (next.startsWith("§7Found: §9")) { + iterator.set("§7Found: §9" + size + "/9 Soul Pieces"); + } else if (next.startsWith("§7Rift Time: §a+")) { + iterator.set("§7Rift Time: §a+" + riftTime + "s"); + } else if (next.startsWith("§7Mana Regen: §a") && pet.rarity == PetInfoOverlay.Rarity.EPIC) { + iterator.set("§7Mana Regen: §a+" + manaRegen + "%"); + } + } getInstance().tooltipToDisplay = tooltip; } } else if (size > 0) { @@ -209,7 +218,6 @@ public class RiftPage extends GuiProfileViewerPage { renderItem("GLASS", 316, 36, guiLeft, guiTop); } - int grubberStacks = rift.castle.grubber_stacks; Utils.renderAlignedString( EnumChatFormatting.GOLD + "Burger:", @@ -258,7 +266,7 @@ public class RiftPage extends GuiProfileViewerPage { } } - if (rift.enigma != null && rift.enigma.found_souls != null ) { + if (rift.enigma != null && rift.enigma.found_souls != null) { int foundSouls = rift.enigma.found_souls.size(); Utils.renderAlignedString( @@ -537,19 +545,19 @@ public class RiftPage extends GuiProfileViewerPage { ); } } - } + } - public static List<JsonObject> readBase64 (String data){ - List<JsonObject> itemStacks = new ArrayList<>(); - try { - NBTTagList items = CompressedStreamTools.readCompressed( - new ByteArrayInputStream(Base64.getDecoder().decode(data)) - ).getTagList("i", 10); - for (int j = 0; j < items.tagCount(); j++) { - JsonObject item = NotEnoughUpdates.INSTANCE.manager.getJsonFromNBTEntry(items.getCompoundTagAt(j)); - itemStacks.add(item); - } - } catch (IOException ignored) { + public static List<JsonObject> readBase64(String data) { + List<JsonObject> itemStacks = new ArrayList<>(); + try { + NBTTagList items = CompressedStreamTools.readCompressed( + new ByteArrayInputStream(Base64.getDecoder().decode(data)) + ).getTagList("i", 10); + for (int j = 0; j < items.tagCount(); j++) { + JsonObject item = NotEnoughUpdates.INSTANCE.manager.getJsonFromNBTEntry(items.getCompoundTagAt(j)); + itemStacks.add(item); + } + } catch (IOException ignored) { } return itemStacks; } |