From cde383d3af47532b62bd8aa13b57f962b43ad55d Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 17 Mar 2024 16:55:09 +0100 Subject: Add /ec warning to storage overlay (#1053) --- .../notenoughupdates/miscfeatures/StorageManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java index 985ed11a..48968e29 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java @@ -175,15 +175,20 @@ public class StorageManager { } private static void fixPetInfo(ItemStack src) { - if (src.getTagCompound() == null || !src.getTagCompound().hasKey("ExtraAttributes") || !src.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("petInfo")) return; - PetInfo oldPetInfo = GSON.fromJson(src.getTagCompound().getCompoundTag("ExtraAttributes").getString("petInfo"), PetInfo.class); + if (src.getTagCompound() == null || !src.getTagCompound().hasKey("ExtraAttributes") || + !src.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("petInfo")) return; + PetInfo oldPetInfo = GSON.fromJson( + src.getTagCompound().getCompoundTag("ExtraAttributes").getString("petInfo"), + PetInfo.class + ); src.getTagCompound().getCompoundTag("ExtraAttributes").removeTag("petInfo"); try { src.getTagCompound().getCompoundTag("ExtraAttributes").setTag( "petInfo", JsonToNBT.getTagFromJson(oldPetInfo.toString()) ); - } catch (NBTException | NullPointerException ignored) {} + } catch (NBTException | NullPointerException ignored) { + } } private static JsonElement loadJson(NBTBase tag) { -- cgit