diff options
author | Ascynx <78341107+Ascynx@users.noreply.github.com> | 2023-09-12 16:29:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-12 16:29:59 +0200 |
commit | 5e69a676854fd48ce33ca1d193d192829b023756 (patch) | |
tree | 5f7622710116bd91e92013de219fa7f492eee3bc /src/main/java/io | |
parent | 1cbf0d27fa1f9b56aaa67fc3b5e2723100fd64ef (diff) | |
download | NotEnoughUpdates-5e69a676854fd48ce33ca1d193d192829b023756.tar.gz NotEnoughUpdates-5e69a676854fd48ce33ca1d193d192829b023756.tar.bz2 NotEnoughUpdates-5e69a676854fd48ce33ca1d193d192829b023756.zip |
Fix rift page crashing when montezuma pet is null (#826)
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/rift/RiftPage.java | 42 |
1 files changed, 23 insertions, 19 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 9dc1ea8d..f7bee433 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 @@ -37,7 +37,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; @@ -129,24 +128,29 @@ public class RiftPage extends GuiProfileViewerPage { int manaRegen = size * 2; JsonObject montezuma = deadCats.getAsJsonObject("montezuma"); - String montezumaType = montezuma.get("type").getAsString(); - - PetInfoOverlay.Pet pet = new PetInfoOverlay.Pet(); - pet.petLevel = new PetLeveling.PetLevel(100, 100, 0, 0, 0, montezuma.get("exp").getAsInt()); - pet.rarity = PetInfoOverlay.Rarity.valueOf(montezuma.get("tier").getAsString().toUpperCase()); - pet.petType = montezumaType; - pet.candyUsed = montezuma.get("candyUsed").getAsInt(); - ItemStack petItemstackFromPetInfo = ItemUtils.createPetItemstackFromPetInfo(pet); - Utils.drawItemStack(petItemstackFromPetInfo, guiLeft + 37, guiTop + 158, true); - - 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"); - tooltip.set(6, "§7Mana Regen: §a+" + manaRegen + "%"); - - getInstance().tooltipToDisplay = tooltip; + if (montezuma != null) { + String montezumaType = montezuma.get("type").getAsString(); + + PetInfoOverlay.Pet pet = new PetInfoOverlay.Pet(); + pet.petLevel = new PetLeveling.PetLevel(100, 100, 0, 0, 0, montezuma.get("exp").getAsInt()); + pet.rarity = PetInfoOverlay.Rarity.valueOf(montezuma.get("tier").getAsString().toUpperCase()); + pet.petType = montezumaType; + pet.candyUsed = montezuma.get("candyUsed").getAsInt(); + ItemStack petItemstackFromPetInfo = ItemUtils.createPetItemstackFromPetInfo(pet); + Utils.drawItemStack(petItemstackFromPetInfo, guiLeft + 37, guiTop + 158, true); + + 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"); + tooltip.set(6, "§7Mana Regen: §a+" + manaRegen + "%"); + + getInstance().tooltipToDisplay = tooltip; + } + } else if (size > 0) { + String montezumaError = EnumChatFormatting.RED + "Could not get pet"; + Utils.drawStringCentered(montezumaError, guiLeft + 91 / 2f, guiTop + 158 + 10, true, 0); } } |