Merge branch 'master' into 1.16
This commit is contained in:
commit
66a02c06cd
4 files changed
+19
-16
No files matched your search
@@ -72,7 +72,10 @@ set(x,y,z,'hopper', l('facing', 'north'), nbt('{Items:[{Slot:1b,id:"minecraft:sl
|
|||||||
|
|
||||||
### `without_updates(expr)`
|
### `without_updates(expr)`
|
||||||
|
|
||||||
Evaluates subexpression without causing updates when blocks change in the world
|
Evaluates subexpression without causing updates when blocks change in the world.
|
||||||
|
|
||||||
|
For synchronization sake, as well as from the fact that suppressed update can only happen within a tick,
|
||||||
|
the call to the `expr` is docked on the main server task.
|
||||||
|
|
||||||
Consider following scenario: We would like to generate a bunch of terrain in a flat world following a perlin noise
|
Consider following scenario: We would like to generate a bunch of terrain in a flat world following a perlin noise
|
||||||
generator. The following code causes a cascading effect as blocks placed on chunk borders will cause other chunks to get
|
generator. The following code causes a cascading effect as blocks placed on chunk borders will cause other chunks to get
|
||||||
|
|||||||
@@ -759,17 +759,22 @@ public class CarpetExpression
|
|||||||
this.expr.addLazyFunction("without_updates", 1, (c, t, lv) ->
|
this.expr.addLazyFunction("without_updates", 1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
boolean previous = CarpetSettings.impendingFillSkipUpdates;
|
boolean previous = CarpetSettings.impendingFillSkipUpdates;
|
||||||
|
if (previous) return lv.get(0);
|
||||||
|
Value [] result = new Value[]{Value.NULL};
|
||||||
|
((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () ->
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CarpetSettings.impendingFillSkipUpdates = true;
|
CarpetSettings.impendingFillSkipUpdates = true;
|
||||||
Value ret = lv.get(0).evalValue(c, t);
|
result[0] = lv.get(0).evalValue(c, t);
|
||||||
return (cc, tt) -> ret;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
CarpetSettings.impendingFillSkipUpdates = previous;
|
CarpetSettings.impendingFillSkipUpdates = previous;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return (cc, tt) -> result[0];
|
||||||
|
});
|
||||||
|
|
||||||
this.expr.addLazyFunction("set", -1, (c, t, lv) ->
|
this.expr.addLazyFunction("set", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
@@ -3249,18 +3254,13 @@ public class CarpetExpression
|
|||||||
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
|
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
|
||||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(dim));
|
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(dim));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
try
|
if (innerSource.getWorld() == outerSource.getWorld()) return lv.get(1);
|
||||||
{
|
Context newCtx = c.recreate();
|
||||||
((CarpetContext) c).s = innerSource;
|
((CarpetContext) newCtx).s = innerSource;
|
||||||
Value retval = lv.get(1).evalValue(c);
|
newCtx.variables = c.variables;
|
||||||
|
Value retval = lv.get(1).evalValue(newCtx);
|
||||||
return (cc, tt) -> retval;
|
return (cc, tt) -> retval;
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
((CarpetContext) c).s = outerSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Context
|
|||||||
public static final int LVALUE = 9;
|
public static final int LVALUE = 9;
|
||||||
public static final int MAPDEF = 10;
|
public static final int MAPDEF = 10;
|
||||||
|
|
||||||
public final Map<String, LazyValue> variables = new HashMap<>();
|
public Map<String, LazyValue> variables = new HashMap<>();
|
||||||
|
|
||||||
public final ScriptHost host;
|
public final ScriptHost host;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"sources": "https://github.com/gnembon/fabric-carpet"
|
"sources": "https://github.com/gnembon/fabric-carpet"
|
||||||
},
|
},
|
||||||
|
|
||||||
"license": "GNU LGPL V3",
|
"license": "MIT",
|
||||||
"icon": "assets/carpet/icon.png",
|
"icon": "assets/carpet/icon.png",
|
||||||
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
|
|||||||
Reference in new issue
Block a user