diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java index 5ca783a6..7665fd71 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicBookshelf.java @@ -84,8 +84,8 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) { var recordPos = BlockAkashicFloodfiller.floodFillFor(pos, world, (here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get())); - if (recordPos != null) { - tile.setNewData(recordPos, tile.getPattern(), DatumType.EMPTY); + if (pOldState.getBlock() != pState.getBlock()) { + tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(), DatumType.EMPTY); } } } diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java index 6836ff46..359f88c0 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockEntityAkashicBookshelf.java @@ -52,22 +52,21 @@ public class BlockEntityAkashicBookshelf extends PaucalBlockEntity { @Override protected void saveModData(CompoundTag compoundTag) { - if (this.recordPos != null) { - compoundTag.put(TAG_RECORD_POS, NbtUtils.writeBlockPos(this.recordPos)); - } - if (this.pattern != null) { - compoundTag.put(TAG_PATTERN, this.pattern.serializeToNBT()); - } + compoundTag.put(TAG_RECORD_POS, this.recordPos == null ? new CompoundTag() : NbtUtils.writeBlockPos(this.recordPos)); + compoundTag.put(TAG_PATTERN, this.pattern == null ? new CompoundTag() : this.pattern.serializeToNBT()); } @Override protected void loadModData(CompoundTag compoundTag) { - if (compoundTag.contains(TAG_RECORD_POS)) { - this.recordPos = NbtUtils.readBlockPos(compoundTag.getCompound(TAG_RECORD_POS)); + CompoundTag recordPos = compoundTag.getCompound(TAG_RECORD_POS); + CompoundTag pattern = compoundTag.getCompound(TAG_PATTERN); + + if (!recordPos.isEmpty()) { + this.recordPos = NbtUtils.readBlockPos(recordPos); } else { this.recordPos = null; } - if (compoundTag.contains(TAG_PATTERN)) { + if (!pattern.isEmpty()) { this.pattern = HexPattern.DeserializeFromNBT(compoundTag.getCompound(TAG_PATTERN)); } else { this.pattern = null;