Merge branch 'master' into 1.16

This commit is contained in:
gnembon committed 2020-03-28 22:03:58 -03:00
commit 419b739d5e
9 files changed
+465 -343

No files matched your search

@@ -133,6 +133,7 @@ import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static carpet.script.utils.WorldTools.canHasChunk;
import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
@@ -677,6 +678,17 @@ public class CarpetExpression
return (c_, t_) -> retval;
});
this.expr.addLazyFunction("is_chunk_generated", -1, (c, t, lv) ->
{
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
BlockPos pos = locator.block.getPos();
boolean force = false;
if (lv.size() > locator.offset)
force = lv.get(locator.offset).evalValue(c, Context.BOOLEAN).getBoolean();
Value retval = new NumericValue(canHasChunk(((CarpetContext)c).s.getWorld(), new ChunkPos(pos), null, force));
return (c_, t_) -> retval;
});
this.expr.addLazyFunction("generation_status", -1, (c, t, lv) ->
{
BlockValue.LocatorResult locatorResult = BlockValue.fromParams((CarpetContext)c, lv, 0);
@@ -1248,14 +1260,24 @@ public class CarpetExpression
ServerWorld world = cc.s.getWorld();
Value [] result = new Value[]{Value.NULL};
((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () ->
{
((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).regenerateChunkRegion(requestedChunks);
Map<String, Integer> report = ((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).regenerateChunkRegion(requestedChunks);
for (ChunkPos chpos: requestedChunks)
{
if (world.getChunk(chpos.x, chpos.z, ChunkStatus.FULL, false) != null)
{
this.forceChunkUpdate(chpos.getCenterBlockPos(), world);
}
}
result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap(
e -> new StringValue((String)((Map.Entry) e).getKey()),
e -> new NumericValue((Integer)((Map.Entry) e).getValue())
)));
});
return LazyValue.NULL;
return (_c, _t) -> result[0];
});
}