Skip to content

Commit 97bb4e0

Browse files
committed
Fix POIs not getting updated with assembly
1 parent 71c5621 commit 97bb4e0

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
290290

291291
final LevelAccelerator accelerator = new LevelAccelerator(level);
292292
final LevelAccelerator resultingAccelerator = new LevelAccelerator(resultingLevel);
293+
final BlockState airState = Blocks.AIR.defaultBlockState();
293294

294295
final List<BlockState> states = new ArrayList<>();
295296

@@ -378,6 +379,8 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
378379
if (state.getBlock() instanceof final BlockSubLevelAssemblyListener listener) {
379380
listener.afterMove(level, resultingLevel, state, block, newPos);
380381
}
382+
383+
level.onBlockStateChange(newPos, airState, state);
381384
} catch (final Exception e) {
382385
Sable.LOGGER.error("Failed to move block {} at {} to {}", state, block, newPos, e);
383386
}
@@ -391,7 +394,7 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
391394
try {
392395
final LevelChunk levelchunk = resultingAccelerator.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()));
393396
final BlockState subLevelState = states.get(i);
394-
SubLevelAssemblyHelper.markAndNotifyBlock(resultingLevel, pos, levelchunk, Blocks.AIR.defaultBlockState(), subLevelState, 3, 512);
397+
SubLevelAssemblyHelper.markAndNotifyBlock(resultingLevel, pos, levelchunk, airState, subLevelState, 3, 512);
395398
} catch (final Exception e) {
396399
Sable.LOGGER.error("Failed to mark & notify block {} (untransformed = {})", pos, untransformed, e);
397400
}
@@ -402,21 +405,20 @@ public static void moveBlocks(final ServerLevel level, final AssemblyTransform t
402405
SableAssemblyPlatform.INSTANCE.setIgnoreOnPlace(resultingLevel, true);
403406
// destroy all the old blocks
404407
for (final BlockPos block : blocks) {
405-
final BlockState subLevelState = Blocks.AIR.defaultBlockState();
406-
407408
try {
408409
final LevelChunk chunk = accelerator.getChunk(SectionPos.blockToSectionCoord(block.getX()),
409410
SectionPos.blockToSectionCoord(block.getZ()));
410411

411-
chunk.setBlockState(block, subLevelState, true);
412+
level.onBlockStateChange(block, chunk.getBlockState(block), airState);
413+
chunk.setBlockState(block, airState, true);
412414
} catch (final Exception e) {
413415
Sable.LOGGER.error("Failed to destroy old block during assembly {}", block, e);
414416
}
415417
}
416418
SableAssemblyPlatform.INSTANCE.setIgnoreOnPlace(resultingLevel, false);
417419

418420
for (final BlockPos block : blocks) {
419-
final BlockState subLevelState = Blocks.AIR.defaultBlockState();
421+
final BlockState subLevelState = airState;
420422
resultingLevel.sendBlockUpdated(block, Blocks.STONE.defaultBlockState(), subLevelState, 3);
421423
}
422424
}

common/src/main/java/dev/ryanhcode/sable/util/SubLevelInclusiveLevelEntityGetter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.ryanhcode.sable.util;
22

33
import dev.ryanhcode.sable.Sable;
4-
import dev.ryanhcode.sable.api.SubLevelHelper;
54
import dev.ryanhcode.sable.companion.math.BoundingBox3d;
65
import dev.ryanhcode.sable.sublevel.SubLevel;
76
import net.minecraft.util.AbortableIterationConsumer;
@@ -90,7 +89,7 @@ public void get(AABB aABB, final Consumer<T> consumer) {
9089
}
9190

9291
@Override
93-
public <U extends T> void get(final EntityTypeTest<T, U> entityTypeTest, AABB aABB, final AbortableIterationConsumer<U> abortableIterationConsumer) {
92+
public <U extends T> void get(final @NotNull EntityTypeTest<T, U> entityTypeTest, AABB aABB, final AbortableIterationConsumer<U> abortableIterationConsumer) {
9493
if (aABB.getSize() > MAX_GET_SIDE_LENGTH) {
9594
logError(aABB);
9695
return;

0 commit comments

Comments
 (0)