mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-02 13:31:41 +01:00
Fix fillHeight
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
b8b850fca1
commit
30aa3ac8f3
@ -366,7 +366,7 @@ final class GeneratorImpl {
|
||||
final boolean endOffset = maxMultiple != maxHeight;
|
||||
if (startOffset || endOffset) {
|
||||
final int firstFill = Math.min(minMultiple + 16, maxHeight);
|
||||
final int lastFill = floorSection(maxHeight);
|
||||
final int lastFill = startOffset ? Math.max(firstFill, floorSection(maxHeight)) : floorSection(maxHeight);
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int z = 0; z < depth; z++) {
|
||||
final int sectionX = startX + x * 16;
|
||||
|
@ -53,15 +53,49 @@ public class GeneratorIntegrationTest {
|
||||
public void fillHeightNegative(Env env) {
|
||||
var manager = env.process().instance();
|
||||
var instance = manager.createInstanceContainer();
|
||||
instance.setGenerator(unit -> {
|
||||
unit.modifier().fillHeight(-64, -60, Block.STONE);
|
||||
});
|
||||
instance.setGenerator(unit -> unit.modifier().fillHeight(-64, -60, Block.STONE));
|
||||
instance.loadChunk(0, 0).join();
|
||||
for (int y = -64; y < -60; y++) {
|
||||
assertEquals(Block.STONE, instance.getBlock(0, y, 0));
|
||||
assertEquals(Block.STONE, instance.getBlock(0, y, 0), "y=" + y);
|
||||
}
|
||||
for (int y = -60; y < 100; y++) {
|
||||
assertEquals(Block.AIR, instance.getBlock(0, y, 0));
|
||||
assertEquals(Block.AIR, instance.getBlock(0, y, 0), "y=" + y);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fillHeightSingleSectionFull(Env env) {
|
||||
var manager = env.process().instance();
|
||||
var instance = manager.createInstanceContainer();
|
||||
instance.setGenerator(unit -> unit.modifier().fillHeight(0, 16, Block.GRASS_BLOCK));
|
||||
instance.loadChunk(0, 0).join();
|
||||
for (int y = 0; y < 16; y++) {
|
||||
assertEquals(Block.GRASS_BLOCK, instance.getBlock(0, y, 0), "y=" + y);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fillHeightSingleSection(Env env) {
|
||||
var manager = env.process().instance();
|
||||
var instance = manager.createInstanceContainer();
|
||||
instance.setGenerator(unit -> unit.modifier().fillHeight(4, 5, Block.GRASS_BLOCK));
|
||||
instance.loadChunk(0, 0).join();
|
||||
for (int y = 0; y < 5; y++) {
|
||||
assertEquals(y == 4 ? Block.GRASS_BLOCK : Block.AIR, instance.getBlock(0, y, 0), "y=" + y);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fillHeightOverride(Env env) {
|
||||
var manager = env.process().instance();
|
||||
var instance = manager.createInstanceContainer();
|
||||
instance.setGenerator(unit -> {
|
||||
unit.modifier().fillHeight(0, 39, Block.GRASS_BLOCK);
|
||||
unit.modifier().fillHeight(39, 40, Block.STONE);
|
||||
});
|
||||
instance.loadChunk(0, 0).join();
|
||||
for (int y = 0; y < 40; y++) {
|
||||
assertEquals(y == 39 ? Block.STONE : Block.GRASS_BLOCK, instance.getBlock(0, y, 0), "y=" + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user