mirror of
https://github.com/Minestom/Minestom.git
synced 2024-07-01 08:54:57 +02: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) {
|
public void fork(@NotNull Consumer<Block.@NotNull Setter> consumer) {
|
||||||
DynamicFork dynamicFork = new DynamicFork();
|
DynamicFork dynamicFork = new DynamicFork();
|
||||||
consumer.accept(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 width = dynamicFork.width;
|
||||||
final int height = dynamicFork.height;
|
final int height = dynamicFork.height;
|
||||||
final int depth = dynamicFork.depth;
|
final int depth = dynamicFork.depth;
|
||||||
final Point startSection = dynamicFork.minSection;
|
|
||||||
final List<GenerationUnit> sections = dynamicFork.sections;
|
final List<GenerationUnit> sections = dynamicFork.sections;
|
||||||
registerFork(startSection, sections, width, height, depth);
|
registerFork(startSection, sections, width, height, depth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
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.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
@ -15,6 +16,23 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
@EnvTest
|
@EnvTest
|
||||||
public class GeneratorForkConsumerIntegrationTest {
|
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
|
@Test
|
||||||
public void local(Env env) {
|
public void local(Env env) {
|
||||||
var manager = env.process().instance();
|
var manager = env.process().instance();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user