mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
fix: Resolve issue with book & quills on lectern contraptions (#7276)
Resolves #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.
This commit is contained in:
parent
d95515a405
commit
773fd257b9
1 changed files with 9 additions and 1 deletions
|
@ -15,13 +15,16 @@ import net.minecraft.nbt.ListTag;
|
|||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.item.EnchantedBookItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public final class NBTProcessors {
|
||||
|
||||
|
@ -43,6 +46,11 @@ public final class NBTProcessors {
|
|||
return data;
|
||||
CompoundTag book = data.getCompound("Book");
|
||||
|
||||
// Writable books can't have click events, so they're safe to keep
|
||||
ResourceLocation writableBookResource = ForgeRegistries.ITEMS.getKey(Items.WRITABLE_BOOK);
|
||||
if (writableBookResource != null && book.getString("id").equals(writableBookResource.toString()))
|
||||
return data;
|
||||
|
||||
if (!book.contains("tag", Tag.TAG_COMPOUND))
|
||||
return data;
|
||||
CompoundTag tag = book.getCompound("tag");
|
||||
|
|
Loading…
Add table
Reference in a new issue