Fixed entity spawn deadlock

- Rise-enabled spawning prepares its starting position inline on the primary thread
- Asynchronous callers keep scheduled preparation
This commit is contained in:
Brian Fopiano authored and GitHub committed 2026-10-28 21:27:01 -04:00
commit 1d4f95829b
1 file changed
+9 -3
@@ -278,14 +278,20 @@ public class IrisEntity extends IrisRegistrant implements NativeEntityOptions {
} }
if (isSpawnEffectRiseOutOfGround()) { if (isSpawnEffectRiseOutOfGround()) {
AtomicReference<Location> f = new AtomicReference<>(at); AtomicReference<Location> f = new AtomicReference<>(at);
try { Runnable riseStart = () -> {
J.sfut(() -> {
if (Chunks.hasPlayersNearby(f.get())) { if (Chunks.hasPlayersNearby(f.get())) {
Location b = f.get().clone(); Location b = f.get().clone();
Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ()); Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ());
f.set(start); 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) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
IrisLogging.reportError("Iris entity spawn preparation was interrupted.", e); IrisLogging.reportError("Iris entity spawn preparation was interrupted.", e);