Skip to content

Commit cab1bfd

Browse files
committed
Remove block entities on assembly to prevent duplication
This also includes a tag for blocks that depend on being properly removed
1 parent 3594364 commit cab1bfd

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

common/src/main/java/dev/ryanhcode/sable/api/SubLevelAssemblyHelper.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import dev.ryanhcode.sable.companion.math.BoundingBox3ic;
1111
import dev.ryanhcode.sable.companion.math.JOMLConversion;
1212
import dev.ryanhcode.sable.companion.math.Pose3d;
13+
import dev.ryanhcode.sable.index.SableTags;
1314
import dev.ryanhcode.sable.platform.SableAssemblyPlatform;
1415
import dev.ryanhcode.sable.sublevel.ServerSubLevel;
1516
import dev.ryanhcode.sable.sublevel.SubLevel;
@@ -348,11 +349,15 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
348349
tag.putInt("z", newPos.getZ());
349350
}
350351

351-
if (blockEntity instanceof final RandomizableContainer container) {
352-
container.setLootTable(null);
353-
}
354-
if (blockEntity instanceof final Clearable clearable) {
355-
clearable.clearContent();
352+
if (state.is(SableTags.REMOVE_ON_ASSEMBLY)) {
353+
if (blockEntity instanceof final RandomizableContainer container) {
354+
container.setLootTable(null);
355+
}
356+
if (blockEntity instanceof final Clearable clearable) {
357+
clearable.clearContent();
358+
}
359+
} else {
360+
level.removeBlockEntity(block);
356361
}
357362

358363
final LevelChunk chunk = resultingAccelerator.getChunk(SectionPos.blockToSectionCoord(newPos.getX()), SectionPos.blockToSectionCoord(newPos.getZ()));

common/src/main/java/dev/ryanhcode/sable/index/SableTags.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public class SableTags {
3636
Sable.sablePath("paddles")
3737
);
3838

39+
public static final TagKey<Block> REMOVE_ON_ASSEMBLY = TagKey.create(
40+
Registries.BLOCK,
41+
Sable.sablePath("remove_on_assembly")
42+
);
43+
3944
public static void register() {
4045
// no-op
4146
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"replace": false,
3+
"values": [
4+
]
5+
}

0 commit comments

Comments
 (0)