added optional force bool

This commit is contained in:
gnembon committed 2019-11-07 07:58:17 -04:00
1 parent ba2d654cec
commit 4997fa5a44
1 file changed
+8 -2
@@ -807,8 +807,14 @@ public class CarpetExpression
this.expr.addLazyFunction("generation_status", -1, (c, t, lv) -> this.expr.addLazyFunction("generation_status", -1, (c, t, lv) ->
{ {
BlockPos pos = BlockValue.fromParams((CarpetContext)c, lv, 0).block.getPos(); BlockValue.LocatorResult locatorResult = BlockValue.fromParams((CarpetContext)c, lv, 0);
Chunk chunk = ((CarpetContext)c).s.getWorld().getChunk(pos.getX()>>4, pos.getZ()>>4, ChunkStatus.EMPTY); BlockPos pos = locatorResult.block.getPos();
boolean forceLoad = false;
if (lv.size() > locatorResult.offset)
forceLoad = lv.get(locatorResult.offset).evalValue(c, Context.BOOLEAN).getBoolean();
Chunk chunk = ((CarpetContext)c).s.getWorld().getChunk(pos.getX()>>4, pos.getZ()>>4, ChunkStatus.EMPTY, forceLoad);
if (chunk == null)
return LazyValue.NULL;
Value retval = new StringValue(chunk.getStatus().getName()); Value retval = new StringValue(chunk.getStatus().getName());
return (c_, t_) -> retval; return (c_, t_) -> retval;
}); });