From 20f405a80907b6a8923bb91deea89eb0a2fbe3df Mon Sep 17 00:00:00 2001 From: Tara Date: Sat, 21 Jan 2023 19:41:10 -0700 Subject: [PATCH] Add some extra code statements as NBT was not updating properly --- gradle.properties | 2 +- .../libzontreck/items/lore/LoreContainer.java | 16 ++++++++++++---- src/main/resources/META-INF/mods.toml | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 73911a0..9778c45 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ org.gradle.daemon=false mc_version=1.19.2 forge_version=43.2.3 -myversion=1.0.3.1 \ No newline at end of file +myversion=1.0.3.2 \ No newline at end of file diff --git a/src/main/java/dev/zontreck/libzontreck/items/lore/LoreContainer.java b/src/main/java/dev/zontreck/libzontreck/items/lore/LoreContainer.java index f0647e1..556430f 100644 --- a/src/main/java/dev/zontreck/libzontreck/items/lore/LoreContainer.java +++ b/src/main/java/dev/zontreck/libzontreck/items/lore/LoreContainer.java @@ -56,10 +56,17 @@ public class LoreContainer { AssertLoreExists(); // Set the Lore - ListTag lst = associatedItem.getTag().getCompound(ItemStack.TAG_DISPLAY).getList(ItemStack.TAG_LORE, Tag.TAG_STRING); + CompoundTag tag = associatedItem.getTag(); + CompoundTag display = tag.getCompound(ItemStack.TAG_DISPLAY); + ListTag lore = display.getList(ItemStack.TAG_LORE, Tag.TAG_STRING); // Set the lore entry - SetOrUpdateIndex(lst, loreEntryNumber, StringTag.valueOf(miscData.saveJson())); + SetOrUpdateIndex(lore, loreEntryNumber, StringTag.valueOf(miscData.saveJson())); + display.put(ItemStack.TAG_LORE, lore); + tag.put(ItemStack.TAG_DISPLAY, display); + associatedItem.setTag(tag); + + } private void SetOrUpdateIndex(ListTag lst, int pos, Tag insert) @@ -92,6 +99,7 @@ public class LoreContainer { if(display==null) { tag.put(ItemStack.TAG_DISPLAY, new CompoundTag()); + associatedItem.setTag(tag); } } @@ -105,8 +113,8 @@ public class LoreContainer { { lore = new ListTag(); display.put(ItemStack.TAG_LORE, lore); - //tag.put(ItemStack.TAG_DISPLAY, display); - //associatedItem.setTag(tag); + tag.put(ItemStack.TAG_DISPLAY, display); + associatedItem.setTag(tag); } } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 2997d59..5776388 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ modId="libzontreck" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # see the associated build.gradle script for how to populate this completely automatically during a build -version="1.0.3.1" #mandatory +version="1.0.3.2" #mandatory # A display name for the mod displayName="LibZontreck" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/