mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:12:54 +08:00
Fix race condition with worktops (#2216)
* Fix race condition with worktops * Update ScriptLib.java * Update ScriptLib.java --------- Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
parent
86036682d7
commit
9d94888da3
@ -158,8 +158,7 @@ public class ScriptLib {
|
|||||||
var configId = callParams.param1;
|
var configId = callParams.param1;
|
||||||
var entity = getSceneScriptManager().getScene().getEntityByConfigId(configId);
|
var entity = getSceneScriptManager().getScene().getEntityByConfigId(configId);
|
||||||
|
|
||||||
|
var worktopOptions = new int[table.length()];
|
||||||
int[] worktopOptions = new int[table.length()];
|
|
||||||
for (int i = 1; i<=table.length(); i++) {
|
for (int i = 1; i<=table.length(); i++) {
|
||||||
worktopOptions[i-1] = table.get(i).optint(-1);
|
worktopOptions[i-1] = table.get(i).optint(-1);
|
||||||
}
|
}
|
||||||
@ -172,9 +171,10 @@ public class ScriptLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
worktop.addWorktopOptions(worktopOptions);
|
worktop.addWorktopOptions(worktopOptions);
|
||||||
|
// Done in order to synchronize with addEntities in Scene.class.
|
||||||
var scene = getSceneScriptManager().getScene();
|
synchronized (this.getSceneScriptManager().getScene()) {
|
||||||
scene.broadcastPacket(new PacketWorktopOptionNotify(gadget));
|
scene.broadcastPacket(new PacketWorktopOptionNotify(gadget));
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user