Prevent TickThreads from stopping if something weird happens

This commit is contained in:
themode 2021-09-21 21:31:02 +02:00
parent e97f1db184
commit 1d8addaea6

View File

@ -36,14 +36,20 @@ public final class TickThread extends Thread {
public void run() { public void run() {
LockSupport.park(this); LockSupport.park(this);
while (!stop) { while (!stop) {
tick(); this.lock.lock();
try {
tick();
} catch (Exception e) {
MinecraftServer.getExceptionManager().handleException(e);
}
this.lock.unlock();
// #acquire() callbacks
this.phaser.arriveAndDeregister(); this.phaser.arriveAndDeregister();
LockSupport.park(this); LockSupport.park(this);
} }
} }
private void tick() { private void tick() {
this.lock.lock();
for (ThreadDispatcher.ChunkEntry entry : entries) { for (ThreadDispatcher.ChunkEntry entry : entries) {
final Chunk chunk = entry.chunk(); final Chunk chunk = entry.chunk();
try { try {
@ -67,8 +73,6 @@ public final class TickThread extends Thread {
} }
} }
} }
this.lock.unlock();
// #acquire() callbacks
} }
void startTick(long tickTime) { void startTick(long tickTime) {