Skip to content

Commit

Permalink
fix: Resolve issue with book & quills on lectern contraptions
Browse files Browse the repository at this point in the history
Resolves Creators-of-Create#7253. Where an attempt to parse JSON out of a writable book (not a written book), which has raw string data for the pages array caused a game crash.
  • Loading branch information
itisluiz committed Jan 10, 2025
1 parent 18fb3b4 commit ebc65f6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public static synchronized void addSurvivalProcessor(BlockEntityType<?> type,
return data;
CompoundTag tag = book.getCompound("tag");

// Check for book & quill, which does not have json pages and
// therefore can't have click events. Written books have an "author" tag.
if (!tag.contains("author", Tag.TAG_LIST))
return data;

if (!tag.contains("pages", Tag.TAG_LIST))
return data;
ListTag pages = tag.getList("pages", Tag.TAG_STRING);
Expand All @@ -67,7 +72,7 @@ public static synchronized void addSurvivalProcessor(BlockEntityType<?> type,
if (!book.contains("tag", Tag.TAG_COMPOUND))
return data;
CompoundTag itemData = book.getCompound("tag");

for (List<String> entries : NBTHelper.readCompoundList(itemData.getList("Pages", Tag.TAG_COMPOUND),
pageTag -> NBTHelper.readCompoundList(pageTag.getList("Entries", Tag.TAG_COMPOUND),
tag -> tag.getString("Text")))) {
Expand Down

0 comments on commit ebc65f6

Please sign in to comment.