entity load handler and rework of handling of events.

This commit is contained in:
gnembon committed 2020-10-30 22:59:27 -03:00
1 parent 51f34643db
commit 7ccd46433a
15 files changed
+413 -299

No files matched your search

@@ -109,7 +109,7 @@ public class CarpetScriptHost extends ScriptHost
// this is nasty, we have the host and function, yet we add it via names, but hey - works for now
String event = funName.replaceFirst("__on_", "");
if (CarpetEventServer.Event.byName.containsKey(event))
scriptServer.events.addEventDirectly(event, this, function);
scriptServer.events.addEventDirectly(event, this, function, null);
}
else if (funName.equals("__config"))
{
@@ -305,12 +305,12 @@ public class CarpetScriptHost extends ScriptHost
}
}
public Value callUDF(BlockPos pos, ServerCommandSource source, FunctionValue fun, List<LazyValue> argv) throws InvalidCallbackException
public Value callUDF(BlockPos pos, ServerCommandSource source, FunctionValue fun, List<Value> argv) throws InvalidCallbackException
{
if (CarpetServer.scriptServer.stopAll)
return Value.NULL;
try { // cause we can't throw checked exceptions in lambda. Left if be until need to handle these more gracefully
fun.assertArgsOk(argv.size(), (b) -> {
fun.assertArgsOk(argv, (b) -> {
throw new InternalExpressionException("");
});
}
@@ -323,7 +323,7 @@ public class CarpetScriptHost extends ScriptHost
// TODO: this is just for now - invoke would be able to invoke other hosts scripts
Context context = new CarpetContext(this, source, pos);
return fun.getExpression().evalValue(
() -> fun.lazyEval(context, Context.VOID, fun.getExpression(), fun.getToken(), argv),
() -> fun.lazyEval(context, Context.VOID, fun.getExpression(), fun.getToken(), FunctionValue.lazify(argv)),
context,
Context.VOID);
}
@@ -334,6 +334,7 @@ public class CarpetScriptHost extends ScriptHost
return Value.NULL;
}
@Override
public void onClose()
{