From cf3624692e36eb482326d8247de019c4d7b21ee4 Mon Sep 17 00:00:00 2001 From: Talia-12 Date: Fri, 2 Jun 2023 00:10:35 +1000 Subject: [PATCH] Fixed #381 (see the issue for details on why this works). --- .../blocks/akashic/BlockEntityAkashicBookshelf.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java index 7fe9945c..fe10b759 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java @@ -13,6 +13,7 @@ import org.jetbrains.annotations.Nullable; public class BlockEntityAkashicBookshelf extends HexBlockEntity { public static final String TAG_PATTERN = "pattern"; public static final String TAG_IOTA = "iota"; + public static final String TAG_DUMMY = "dummy"; // This is only not null if this stores any data. private HexPattern pattern = null; @@ -55,8 +56,6 @@ public class BlockEntityAkashicBookshelf extends HexBlockEntity { this.pattern = null; this.iotaTag = null; - this.setChanged(); - if (!previouslyEmpty) { var oldBs = this.getBlockState(); var newBs = oldBs.setValue(BlockAkashicBookshelf.HAS_BOOKS, false); @@ -72,6 +71,8 @@ public class BlockEntityAkashicBookshelf extends HexBlockEntity { if (this.pattern != null && this.iotaTag != null) { compoundTag.put(TAG_PATTERN, this.pattern.serializeToNBT()); compoundTag.put(TAG_IOTA, this.iotaTag); + } else { + compoundTag.putBoolean(TAG_DUMMY, false); } } @@ -80,6 +81,9 @@ public class BlockEntityAkashicBookshelf extends HexBlockEntity { if (tag.contains(TAG_PATTERN) && tag.contains(TAG_IOTA)) { this.pattern = HexPattern.fromNBT(tag.getCompound(TAG_PATTERN)); this.iotaTag = tag.getCompound(TAG_IOTA); + } else if (tag.contains(TAG_DUMMY)) { + this.pattern = null; + this.iotaTag = null; } } }