From 920eaaec31363d01015816cc37c1ad570c9f188c Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Thu, 9 Jan 2025 15:55:03 +0000 Subject: [PATCH] fix: fix to last reward table commit --- .../ftb/mods/ftbquests/quest/loot/RewardTable.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/loot/RewardTable.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/loot/RewardTable.java index e61ae740..403b0510 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/loot/RewardTable.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/loot/RewardTable.java @@ -226,9 +226,15 @@ public void readData(CompoundTag nbt, HolderLookup.Provider provider) { for (int i = 0; i < list.size(); i++) { boolean newReward = false; CompoundTag rewardTag = list.getCompound(i); - long rewardId = file.getID(rewardTag.get("id")); - if (rewardId == 0L) { - // should only occur on server when the client has sent a reward table with new reward(s) + if (!rewardTag.contains("id") && file.isServerSide()) { + // can happen on server when reading in an older quest book where reward table rewards didn't have IDs + rewardTag.putString("id", QuestObjectBase.getCodeString(file.newID())); + } + long rewardId = QuestObjectBase.parseCodeString(rewardTag.getString("id")); + if (rewardId == 0L && file.isServerSide()) { + // Can happen on server when the client has sent a reward table with new reward(s) + // Note: can also happen on client when copying rewards that haven't been sent to server yet (reward editor screen) + // - in that case, an id of 0 is fine, so don't do anything here rewardId = file.newID(); rewardTag.putString("id", QuestObjectBase.getCodeString(rewardId)); newReward = refreshIds = true;