From d01686392645823f4d394dd3061a9d18607ec58d Mon Sep 17 00:00:00 2001 From: IridescentVoid <265486018+iridescentvoid@users.noreply.github.com> Date: Fri, 5 Jun 2026 10:22:59 -0700 Subject: [PATCH 1/2] Allow overwriting akashic libraries --- .../blocks/akashic/BlockAkashicRecord.java | 21 ++++++++++--------- .../akashic/BlockEntityAkashicBookshelf.java | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java index db3f96ac14..7ad6a1724c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/akashic/BlockAkashicRecord.java @@ -22,24 +22,25 @@ public BlockAkashicRecord(Properties p_49795_) { */ public @Nullable BlockPos addNewDatum(BlockPos herePos, Level level, HexPattern key, Iota datum) { - var clobbereePos = AkashicFloodfiller.floodFillFor(herePos, level, + // Look for existing shelf with the same pattern to overwrite + var targetPos = AkashicFloodfiller.floodFillFor(herePos, level, (pos, bs, world) -> world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile && tile.getPattern() != null && tile.getPattern().sigsEqual(key)); - if (clobbereePos != null) { - return null; + if (targetPos == null) { + // Otherwise find an empty shelf + targetPos = AkashicFloodfiller.floodFillFor(herePos, level, 0.9f, + (pos, bs, world) -> + world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile + && tile.getPattern() == null, 128); } - var openPos = AkashicFloodfiller.floodFillFor(herePos, level, 0.9f, - (pos, bs, world) -> - world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile - && tile.getPattern() == null, 128); - if (openPos != null) { - var tile = (BlockEntityAkashicBookshelf) level.getBlockEntity(openPos); + if (targetPos != null) { + var tile = (BlockEntityAkashicBookshelf) level.getBlockEntity(targetPos); tile.setNewMapping(key, datum); - return openPos; + return targetPos; } else { return null; } 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 d6e4cd8041..a2c2280b36 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 @@ -44,12 +44,13 @@ public void setNewMapping(HexPattern pattern, Iota iota) { this.pattern = pattern; this.iotaTag = IotaType.serialize(iota); + var oldBs = this.getBlockState(); if (previouslyEmpty) { - var oldBs = this.getBlockState(); var newBs = oldBs.setValue(BlockAkashicBookshelf.HAS_BOOKS, true); - this.level.setBlock(this.getBlockPos(), newBs, 3); this.level.sendBlockUpdated(this.getBlockPos(), oldBs, newBs, 3); + this.level.setBlock(this.getBlockPos(), newBs, 3); } else { + this.level.sendBlockUpdated(this.getBlockPos(), oldBs, oldBs, 3); this.setChanged(); } } From 1d1099b25eade717cbbf640a2908cae033f10861 Mon Sep 17 00:00:00 2001 From: IridescentVoid <265486018+IridescentVoid@users.noreply.github.com> Date: Sun, 7 Jun 2026 12:17:54 -0700 Subject: [PATCH 2/2] Fix bookshelf writes not saving properly --- .../common/blocks/akashic/BlockEntityAkashicBookshelf.java | 4 ++-- 1 file changed, 2 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 a2c2280b36..1cf96afb52 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 @@ -47,11 +47,11 @@ public void setNewMapping(HexPattern pattern, Iota iota) { var oldBs = this.getBlockState(); if (previouslyEmpty) { var newBs = oldBs.setValue(BlockAkashicBookshelf.HAS_BOOKS, true); - this.level.sendBlockUpdated(this.getBlockPos(), oldBs, newBs, 3); this.level.setBlock(this.getBlockPos(), newBs, 3); + this.level.sendBlockUpdated(this.getBlockPos(), oldBs, newBs, 3); } else { - this.level.sendBlockUpdated(this.getBlockPos(), oldBs, oldBs, 3); this.setChanged(); + this.level.sendBlockUpdated(this.getBlockPos(), oldBs, oldBs, 3); } }