mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Keep native structures out of static object cells
Vanilla structure and feature placement now runs through the bounded worldgen access with a protected-position predicate, so a jigsaw piece or an imported feature can read a static object's blocks but never overwrite them, and never schedules a tick or block entity there. Dimensions without static objects keep the plain level as before.
This commit is contained in:
10 files changed
+129
-36
No files matched your search
+29
-1
@@ -135,6 +135,34 @@ public class ModdedNativeStructureWorldgenAccessTest {
|
||||
assertEquals(1, recording.blockTicks.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void protectedCellsRemainReadableButRejectWritesTilesAndTicks() {
|
||||
RecordingDelegate recording = new RecordingDelegate();
|
||||
BlockPos position = generationCenter().getMiddleBlockPosition(70);
|
||||
ModdedNativeStructureWorldgenAccess access = ModdedNativeStructureWorldgenAccess.create(
|
||||
recording.world(), generationCenter(),
|
||||
(x, z) -> SURFACE_FIRST_FREE_Y,
|
||||
(x, z) -> FLOOR_FIRST_FREE_Y, position::equals);
|
||||
|
||||
assertSame(Blocks.DIRT, access.getBlockState(position).getBlock());
|
||||
assertFalse(access.ensureCanWrite(position));
|
||||
assertFalse(access.setBlock(position, Blocks.STONE.defaultBlockState(), 2));
|
||||
assertFalse(access.removeBlock(position, false));
|
||||
assertFalse(access.destroyBlock(position, false));
|
||||
assertNull(access.getBlockEntity(position));
|
||||
assertTrue(access.getBlockEntity(position, null).isEmpty());
|
||||
access.getBlockTicks().schedule(new ScheduledTick<>(Blocks.DIRT, position, 1L, 0L));
|
||||
access.updateNeighborsAt(position.east(), Blocks.DIRT);
|
||||
access.neighborShapeChanged(
|
||||
Direction.EAST, position, position.east(), Blocks.DIRT.defaultBlockState(), 2, 512);
|
||||
|
||||
assertEquals(1, recording.terrainReads);
|
||||
assertEquals(0, recording.mutations);
|
||||
assertEquals(0, recording.blockTicks.count());
|
||||
assertTrue(access.setBlock(position.above(), Blocks.STONE.defaultBlockState(), 2));
|
||||
assertEquals(1, recording.mutations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statuslessChunkReadsPreserveWorldgenDelegateSemantics() {
|
||||
RecordingDelegate recording = new RecordingDelegate();
|
||||
@@ -183,7 +211,7 @@ public class ModdedNativeStructureWorldgenAccessTest {
|
||||
return ModdedNativeStructureWorldgenAccess.create(
|
||||
recording.world(), generationCenter(),
|
||||
(x, z) -> SURFACE_FIRST_FREE_Y,
|
||||
(x, z) -> FLOOR_FIRST_FREE_Y);
|
||||
(x, z) -> FLOOR_FIRST_FREE_Y, position -> false);
|
||||
}
|
||||
|
||||
private static ChunkPos generationCenter() {
|
||||
|
||||
+2
-2
@@ -103,12 +103,12 @@ public class NativeStructureFailureContractTest {
|
||||
@Test
|
||||
public void nativeStructurePostProcessingUsesBoundedWorldgenAccess() throws IOException {
|
||||
String source = moddedSource("ModdedNativeStructureStage.java");
|
||||
int placementStart = source.indexOf("private void placeVanillaStructure");
|
||||
int placementStart = source.indexOf("void placeVanillaStructures");
|
||||
int placementEnd = source.indexOf("private List<List<Structure>> structuresByStep", placementStart);
|
||||
String placement = source.substring(placementStart, placementEnd);
|
||||
|
||||
assertTrue(placement.contains("ModdedNativeStructureWorldgenAccess.create("));
|
||||
assertTrue(placement.contains("NativeStructurePostProcessor.place(\n boundedWorld"));
|
||||
assertTrue(placement.contains("placeVanillaStructure(boundedWorld, structureManager"));
|
||||
assertFalse(placement.contains("NativeStructurePostProcessor.place(world,"));
|
||||
assertTrue(placement.contains("world.setCurrentlyGenerating(null);"));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user