mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-23 07:41:37 +01:00
Fix empty fork
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
3371de9556
commit
821063addf
@ -184,10 +184,12 @@ final class GeneratorImpl {
|
||||
public void fork(@NotNull Consumer<Block.@NotNull Setter> consumer) {
|
||||
DynamicFork dynamicFork = new DynamicFork();
|
||||
consumer.accept(dynamicFork);
|
||||
final Point startSection = dynamicFork.minSection;
|
||||
if (startSection == null)
|
||||
return; // No block has been placed
|
||||
final int width = dynamicFork.width;
|
||||
final int height = dynamicFork.height;
|
||||
final int depth = dynamicFork.depth;
|
||||
final Point startSection = dynamicFork.minSection;
|
||||
final List<GenerationUnit> sections = dynamicFork.sections;
|
||||
registerFork(startSection, sections, width, height, depth);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
@ -15,6 +16,23 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
@EnvTest
|
||||
public class GeneratorForkConsumerIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void empty(Env env) {
|
||||
var manager = env.process().instance();
|
||||
var instance = manager.createInstanceContainer();
|
||||
AtomicReference<Exception> failed = new AtomicReference<>();
|
||||
instance.setGenerator(unit -> {
|
||||
try {
|
||||
unit.fork(setter -> {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
failed.set(e);
|
||||
}
|
||||
});
|
||||
instance.loadChunk(0, 0).join();
|
||||
assertNull(failed.get(), "Failed: " + failed.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void local(Env env) {
|
||||
var manager = env.process().instance();
|
||||
|
Loading…
Reference in New Issue
Block a user