Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -540,4 +552,4 @@ public enum State {
}
}
}
}
}