This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-20 16:18:01 -04:00
1 parent 2fa0853e42
commit 8e3ef1b651
45 files changed
+1036 -36

No files matched your search

@@ -1895,6 +1895,72 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(raised, 0, 68, 0));
}
@Test
public void loweredSnowSurfaceRemovesSolidSlabDecoration() {
Map<BlockPos, BlockState> blocks = new HashMap<>();
for (int y = 82; y < 99; y++) {
put(blocks, 0, y, 0, Blocks.STONE.defaultBlockState());
}
put(blocks, 0, 99, 0, Blocks.SNOW_BLOCK.defaultBlockState());
put(blocks, 0, 100, 0, Blocks.COBBLESTONE_SLAB.defaultBlockState());
NativeStructureSurfaceFitter.applySurfaceColumn(
world(blocks), new BlockPos.MutableBlockPos(),
0, 0, 99, 83, -64, 319);
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 82, 0));
assertEquals(Blocks.SNOW_BLOCK.defaultBlockState(), state(blocks, 0, 83, 0));
for (int y = 84; y <= 100; y++) {
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, y, 0));
}
}
@Test
public void loweredSurfaceRemovesStackedSolidDecorationUntilAir() {
Map<BlockPos, BlockState> blocks = new HashMap<>();
put(blocks, 0, 62, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 63, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 64, 0, Blocks.GRASS_BLOCK.defaultBlockState());
put(blocks, 0, 65, 0, Blocks.COBBLESTONE.defaultBlockState());
put(blocks, 0, 66, 0, Blocks.COBBLESTONE_STAIRS.defaultBlockState());
put(blocks, 0, 67, 0, Blocks.COBBLESTONE_WALL.defaultBlockState());
put(blocks, 0, 69, 0, Blocks.STONE.defaultBlockState());
NativeStructureSurfaceFitter.applySurfaceColumn(
world(blocks), new BlockPos.MutableBlockPos(),
0, 0, 64, 62, -64, 319);
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 62, 0));
for (int y = 63; y <= 68; y++) {
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, y, 0));
}
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 69, 0));
}
@Test
public void loweredSurfacePreservesTreeDecorationBoundary() {
for (BlockState tree : List.of(Blocks.OAK_LOG.defaultBlockState(), Blocks.OAK_LEAVES.defaultBlockState())) {
Map<BlockPos, BlockState> blocks = new HashMap<>();
put(blocks, 0, 62, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 63, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 64, 0, Blocks.GRASS_BLOCK.defaultBlockState());
put(blocks, 0, 65, 0, Blocks.COBBLESTONE_SLAB.defaultBlockState());
put(blocks, 0, 66, 0, tree);
put(blocks, 0, 67, 0, Blocks.STONE.defaultBlockState());
NativeStructureSurfaceFitter.applySurfaceColumn(
world(blocks), new BlockPos.MutableBlockPos(),
0, 0, 64, 62, -64, 319);
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 62, 0));
for (int y = 63; y <= 65; y++) {
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, y, 0));
}
assertEquals(tree, state(blocks, 0, 66, 0));
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 67, 0));
}
}
@Test
public void rigidSurfaceBaseClosesAOneBlockSubsurfaceGap() {
Map<BlockPos, BlockState> blocks = new HashMap<>();
@@ -239,8 +239,8 @@ public class NativeStructurePostProcessorVegetationTest {
}
@Test
public void loweringSurfaceKeepsTreeAndSolidObjectBoundaries() {
for (BlockState boundary : List.of(Blocks.OAK_LOG.defaultBlockState(), Blocks.OAK_PLANKS.defaultBlockState())) {
public void loweringSurfaceKeepsTreeBoundaries() {
for (BlockState boundary : List.of(Blocks.OAK_LOG.defaultBlockState(), Blocks.OAK_LEAVES.defaultBlockState())) {
ProtoChunk chunk = chunk();
write(chunk, 4, 63, 4, Blocks.SAND.defaultBlockState());
write(chunk, 4, 64, 4, Blocks.SAND.defaultBlockState());
@@ -257,6 +257,34 @@ public class NativeStructurePostProcessorVegetationTest {
}
}
@Test
public void loweringSurfaceRemovesUnsupportedPlankDecoration() {
ProtoChunk chunk = chunk();
for (int x : List.of(4, 5)) {
for (int y = 60; y <= 64; y++) {
write(chunk, x, y, 4, Blocks.SAND.defaultBlockState());
}
write(chunk, x, 65, 4, Blocks.OAK_PLANKS.defaultBlockState());
write(chunk, x, 66, 4, Blocks.CACTUS.defaultBlockState());
write(chunk, x, 67, 4, Blocks.CACTUS_FLOWER.defaultBlockState());
}
WorldGenLevel world = world(chunk);
NativeStructureSurfaceFitter.applySurfaceColumn(
world, new BlockPos.MutableBlockPos(), 4, 4, 64, 60, MIN_Y, MAX_Y);
NativeStructureSurfaceFitter.applySurfaceColumn(
world, new BlockPos.MutableBlockPos(), 5, 4, 64, 64, MIN_Y, MAX_Y);
assertEquals(Blocks.SAND.defaultBlockState(), chunk.getBlockState(new BlockPos(4, 60, 4)));
for (int y = 61; y <= 67; y++) {
assertTrue(chunk.getBlockState(new BlockPos(4, y, 4)).isAir());
}
assertEquals(Blocks.SAND.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 64, 4)));
assertEquals(Blocks.OAK_PLANKS.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 65, 4)));
assertEquals(Blocks.CACTUS.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 66, 4)));
assertEquals(Blocks.CACTUS_FLOWER.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 67, 4)));
}
private static void clearVegetation(ProtoChunk chunk, StructureStart start) {
NativeStructureVegetationClearer.clearIntersectingVegetation(
world(chunk), chunk, AREA, List.of(start));
@@ -1895,6 +1895,72 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(raised, 0, 68, 0));
}
@Test
public void loweredSnowSurfaceRemovesSolidSlabDecoration() {
Map<BlockPos, BlockState> blocks = new HashMap<>();
for (int y = 82; y < 99; y++) {
put(blocks, 0, y, 0, Blocks.STONE.defaultBlockState());
}
put(blocks, 0, 99, 0, Blocks.SNOW_BLOCK.defaultBlockState());
put(blocks, 0, 100, 0, Blocks.COBBLESTONE_SLAB.defaultBlockState());
NativeStructureSurfaceFitter.applySurfaceColumn(
world(blocks), new BlockPos.MutableBlockPos(),
0, 0, 99, 83, -64, 319);
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 82, 0));
assertEquals(Blocks.SNOW_BLOCK.defaultBlockState(), state(blocks, 0, 83, 0));
for (int y = 84; y <= 100; y++) {
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, y, 0));
}
}
@Test
public void loweredSurfaceRemovesStackedSolidDecorationUntilAir() {
Map<BlockPos, BlockState> blocks = new HashMap<>();
put(blocks, 0, 62, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 63, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 64, 0, Blocks.GRASS_BLOCK.defaultBlockState());
put(blocks, 0, 65, 0, Blocks.COBBLESTONE.defaultBlockState());
put(blocks, 0, 66, 0, Blocks.COBBLESTONE_STAIRS.defaultBlockState());
put(blocks, 0, 67, 0, Blocks.COBBLESTONE_WALL.defaultBlockState());
put(blocks, 0, 69, 0, Blocks.STONE.defaultBlockState());
NativeStructureSurfaceFitter.applySurfaceColumn(
world(blocks), new BlockPos.MutableBlockPos(),
0, 0, 64, 62, -64, 319);
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 62, 0));
for (int y = 63; y <= 68; y++) {
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, y, 0));
}
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 69, 0));
}
@Test
public void loweredSurfacePreservesTreeDecorationBoundary() {
for (BlockState tree : List.of(Blocks.OAK_LOG.defaultBlockState(), Blocks.OAK_LEAVES.defaultBlockState())) {
Map<BlockPos, BlockState> blocks = new HashMap<>();
put(blocks, 0, 62, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 63, 0, Blocks.DIRT.defaultBlockState());
put(blocks, 0, 64, 0, Blocks.GRASS_BLOCK.defaultBlockState());
put(blocks, 0, 65, 0, Blocks.COBBLESTONE_SLAB.defaultBlockState());
put(blocks, 0, 66, 0, tree);
put(blocks, 0, 67, 0, Blocks.STONE.defaultBlockState());
NativeStructureSurfaceFitter.applySurfaceColumn(
world(blocks), new BlockPos.MutableBlockPos(),
0, 0, 64, 62, -64, 319);
assertEquals(Blocks.GRASS_BLOCK.defaultBlockState(), state(blocks, 0, 62, 0));
for (int y = 63; y <= 65; y++) {
assertEquals(Blocks.AIR.defaultBlockState(), state(blocks, 0, y, 0));
}
assertEquals(tree, state(blocks, 0, 66, 0));
assertEquals(Blocks.STONE.defaultBlockState(), state(blocks, 0, 67, 0));
}
}
@Test
public void rigidSurfaceBaseClosesAOneBlockSubsurfaceGap() {
Map<BlockPos, BlockState> blocks = new HashMap<>();
@@ -239,8 +239,8 @@ public class NativeStructurePostProcessorVegetationTest {
}
@Test
public void loweringSurfaceKeepsTreeAndSolidObjectBoundaries() {
for (BlockState boundary : List.of(Blocks.OAK_LOG.defaultBlockState(), Blocks.OAK_PLANKS.defaultBlockState())) {
public void loweringSurfaceKeepsTreeBoundaries() {
for (BlockState boundary : List.of(Blocks.OAK_LOG.defaultBlockState(), Blocks.OAK_LEAVES.defaultBlockState())) {
ProtoChunk chunk = chunk();
write(chunk, 4, 63, 4, Blocks.SAND.defaultBlockState());
write(chunk, 4, 64, 4, Blocks.SAND.defaultBlockState());
@@ -257,6 +257,34 @@ public class NativeStructurePostProcessorVegetationTest {
}
}
@Test
public void loweringSurfaceRemovesUnsupportedPlankDecoration() {
ProtoChunk chunk = chunk();
for (int x : List.of(4, 5)) {
for (int y = 60; y <= 64; y++) {
write(chunk, x, y, 4, Blocks.SAND.defaultBlockState());
}
write(chunk, x, 65, 4, Blocks.OAK_PLANKS.defaultBlockState());
write(chunk, x, 66, 4, Blocks.CACTUS.defaultBlockState());
write(chunk, x, 67, 4, Blocks.CACTUS_FLOWER.defaultBlockState());
}
WorldGenLevel world = world(chunk);
NativeStructureSurfaceFitter.applySurfaceColumn(
world, new BlockPos.MutableBlockPos(), 4, 4, 64, 60, MIN_Y, MAX_Y);
NativeStructureSurfaceFitter.applySurfaceColumn(
world, new BlockPos.MutableBlockPos(), 5, 4, 64, 64, MIN_Y, MAX_Y);
assertEquals(Blocks.SAND.defaultBlockState(), chunk.getBlockState(new BlockPos(4, 60, 4)));
for (int y = 61; y <= 67; y++) {
assertTrue(chunk.getBlockState(new BlockPos(4, y, 4)).isAir());
}
assertEquals(Blocks.SAND.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 64, 4)));
assertEquals(Blocks.OAK_PLANKS.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 65, 4)));
assertEquals(Blocks.CACTUS.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 66, 4)));
assertEquals(Blocks.CACTUS_FLOWER.defaultBlockState(), chunk.getBlockState(new BlockPos(5, 67, 4)));
}
private static void clearVegetation(ProtoChunk chunk, StructureStart start) {
NativeStructureVegetationClearer.clearIntersectingVegetation(
world(chunk), chunk, AREA, List.of(start));