mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
fix StructureScript return issues
This commit is contained in:
@@ -102,22 +102,25 @@ public class StructureScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean execute(Location location, Chunk chunk, Random random, Rotation rotation) {
|
public boolean execute(Location location, Chunk chunk, Random random, Rotation rotation) {
|
||||||
StructureBuffer buffer = cache.computeIfAbsent(location, loc -> {
|
StructureBuffer buffer = computeBuffer(location, random, rotation);
|
||||||
StructureBuffer buf = new StructureBuffer(loc);
|
|
||||||
Block.ReturnInfo<?> level = block.apply(new TerraImplementationArguments(buf, rotation, random, 0));
|
|
||||||
buf.setSucceeded(!level.getLevel().equals(Block.ReturnLevel.FAIL));
|
|
||||||
return buf;
|
|
||||||
});
|
|
||||||
buffer.paste(chunk);
|
buffer.paste(chunk);
|
||||||
return buffer.succeeded();
|
return buffer.succeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean test(Location location, Random random, Rotation rotation) {
|
public boolean test(Location location, Random random, Rotation rotation) {
|
||||||
StructureBuffer buffer = new StructureBuffer(location);
|
StructureBuffer buffer = computeBuffer(location, random, rotation);
|
||||||
block.apply(new TerraImplementationArguments(buffer, rotation, random, 0));
|
|
||||||
return buffer.succeeded();
|
return buffer.succeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StructureBuffer computeBuffer(Location location, Random random, Rotation rotation) {
|
||||||
|
return cache.computeIfAbsent(location, loc -> {
|
||||||
|
StructureBuffer buf = new StructureBuffer(loc);
|
||||||
|
Block.ReturnInfo<?> level = block.apply(new TerraImplementationArguments(buf, rotation, random, 0));
|
||||||
|
buf.setSucceeded(!level.getLevel().equals(Block.ReturnLevel.FAIL));
|
||||||
|
return buf;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public boolean executeInBuffer(Buffer buffer, Random random, Rotation rotation, int recursions) {
|
public boolean executeInBuffer(Buffer buffer, Random random, Rotation rotation, int recursions) {
|
||||||
return !block.apply(new TerraImplementationArguments(buffer, rotation, random, recursions)).getLevel().equals(Block.ReturnLevel.FAIL);
|
return !block.apply(new TerraImplementationArguments(buffer, rotation, random, recursions)).getLevel().equals(Block.ReturnLevel.FAIL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user