diff --git a/common/src/main/java/dev/ryanhcode/sable/api/SubLevelAssemblyHelper.java b/common/src/main/java/dev/ryanhcode/sable/api/SubLevelAssemblyHelper.java index c95b740..beecf39 100644 --- a/common/src/main/java/dev/ryanhcode/sable/api/SubLevelAssemblyHelper.java +++ b/common/src/main/java/dev/ryanhcode/sable/api/SubLevelAssemblyHelper.java @@ -390,24 +390,36 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t i++; } + final BlockState subLevelState = Blocks.AIR.defaultBlockState(); + SableAssemblyPlatform.INSTANCE.setIgnoreOnPlace(resultingLevel, true); - // destroy all the old blocks + // Replace all old blocks as barriers temporarily to prevent any brittle blocks from breaking. for (final BlockPos block : blocks) { - final BlockState subLevelState = Blocks.AIR.defaultBlockState(); + try { + final LevelChunk chunk = accelerator.getChunk(SectionPos.blockToSectionCoord(block.getX()), + SectionPos.blockToSectionCoord(block.getZ())); + + chunk.setBlockState(block, Blocks.BARRIER.defaultBlockState(), true); + } catch (final Exception e) { + Sable.LOGGER.error("Failed to replace old block into a temporary barrier during assembly {}", block, e); + } + } + + // Destroy all temporary barriers. + for (final BlockPos block : blocks) { try { final LevelChunk chunk = accelerator.getChunk(SectionPos.blockToSectionCoord(block.getX()), SectionPos.blockToSectionCoord(block.getZ())); chunk.setBlockState(block, subLevelState, true); } catch (final Exception e) { - Sable.LOGGER.error("Failed to destroy old block during assembly {}", block, e); + Sable.LOGGER.error("Failed to destroy temporary barrier during assembly {}", block, e); } } SableAssemblyPlatform.INSTANCE.setIgnoreOnPlace(resultingLevel, false); for (final BlockPos block : blocks) { - final BlockState subLevelState = Blocks.AIR.defaultBlockState(); resultingLevel.sendBlockUpdated(block, Blocks.STONE.defaultBlockState(), subLevelState, 3); } } @@ -540,4 +552,4 @@ public enum State { } } } -} +} \ No newline at end of file