From 95f7c5d0a61e5d82e8ea1396e7a715507fa804a0 Mon Sep 17 00:00:00 2001 From: jhooc77 <41156145+jhooc77@users.noreply.github.com> Date: Wed, 12 Jan 2022 10:17:47 +0900 Subject: [PATCH] Fixed NMSException: Unable to retrieve NBT data (#82) * Convert NBTTagCompound from ItemStack now work well with 1.17 * Update src/main/java/fr/zcraft/quartzlib/components/nbt/NBT.java --- src/main/java/fr/zcraft/quartzlib/components/nbt/NBT.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/zcraft/quartzlib/components/nbt/NBT.java b/src/main/java/fr/zcraft/quartzlib/components/nbt/NBT.java index 58b86114..aced4c8d 100644 --- a/src/main/java/fr/zcraft/quartzlib/components/nbt/NBT.java +++ b/src/main/java/fr/zcraft/quartzlib/components/nbt/NBT.java @@ -305,7 +305,11 @@ private static Object getMcNBTCompound(ItemStack item) throws NMSException { tagCompound = Reflection.call(mcItemStack.getClass(), mcItemStack, "t"); } catch (Exception e) { //1.17 - tagCompound = Reflection.call(mcItemStack.getClass(), mcItemStack, "a"); + try { + tagCompound = Reflection.call(mcItemStack.getClass(), mcItemStack, "getTag"); + } catch (Exception e2) { + tagCompound = Reflection.call(mcItemStack.getClass(), mcItemStack, "a"); + } } if (tagCompound == null) {