mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-30 07:50:03 +00:00
Fix main thread deadlock when spawning rise-out-of-ground entities
IrisEntity.spawn waited on J.sfut(...).get() to move the spawn point below ground. J.sfut schedules the task for the next main thread tick, so when spawn already runs on the main thread (ambient spawning in WorldEntitySpawner) the future can never complete and the server stops ticking. Run the check inline when already on the main thread.
This commit is contained in:
1 parent
f64a7c6753
commit
0c760d9256
1 file changed
+9
-3
@@ -278,14 +278,20 @@ public class IrisEntity extends IrisRegistrant implements NativeEntityOptions {
|
||||
}
|
||||
if (isSpawnEffectRiseOutOfGround()) {
|
||||
AtomicReference<Location> f = new AtomicReference<>(at);
|
||||
try {
|
||||
J.sfut(() -> {
|
||||
Runnable riseStart = () -> {
|
||||
if (Chunks.hasPlayersNearby(f.get())) {
|
||||
Location b = f.get().clone();
|
||||
Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ());
|
||||
f.set(start);
|
||||
}
|
||||
}).get();
|
||||
};
|
||||
try {
|
||||
// J.sfut schedules onto the next main thread tick, so waiting on it from the main thread never returns.
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
riseStart.run();
|
||||
} else {
|
||||
J.sfut(riseStart).get();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
IrisLogging.reportError("Iris entity spawn preparation was interrupted.", e);
|
||||
|
||||
Reference in new issue
Block a user