This commit is contained in:
gnembon committed 2021-06-29 17:28:58 -03:00
1 parent 787eb3e41d
commit 9a4e15da48
28 files changed
+176 -149

No files matched your search

@@ -16,7 +16,7 @@ public class Threading
{
//"overidden" native call to cancel if on main thread
expression.addContextFunction("task_join", 1, (c, t, lv) -> {
if (((CarpetContext)c).s.getMinecraftServer().isOnThread())
if (((CarpetContext)c).s.getServer().isOnThread())
throw new InternalExpressionException("'task_join' cannot be called from main thread to avoid deadlocks");
Value v = lv.get(0);
if (!(v instanceof ThreadValue))
@@ -27,13 +27,13 @@ public class Threading
// has to be lazy due to deferred execution of the expression
expression.addLazyFunctionWithDelegation("task_dock", 1, false,true, (c, t, expr, tok, lv) -> {
CarpetContext cc = (CarpetContext)c;
MinecraftServer server = cc.s.getMinecraftServer();
MinecraftServer server = cc.s.getServer();
if (server.isOnThread()) return lv.get(0); // pass through for on thread tasks
Value[] result = new Value[]{Value.NULL};
RuntimeException[] internal = new RuntimeException[]{null};
try
{
((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() ->
((CarpetContext) c).s.getServer().submitAndJoin(() ->
{
try
{