Skip to content

Commit

Permalink
fix: log async catcher messages in case the offending mod swallows it
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Feb 12, 2024
1 parent 97eef75 commit 3fcb0a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.ConcurrentModificationException;

@Mixin(ServerChunkManager.class)
public class MixinServerChunkManager {

@Shadow @Final private Thread serverThread;

@Inject(method = "tick(Ljava/util/function/BooleanSupplier;Z)V", at = @At("HEAD"))
private void onTick(CallbackInfo ci) {
if (Thread.currentThread() != this.serverThread) throw new IllegalStateException("Async ticking server chunk manager");
if (Thread.currentThread() != this.serverThread) {
final ConcurrentModificationException e = new ConcurrentModificationException("Async ticking server chunk manager");
e.printStackTrace();
throw e;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ public class MixinThreadedAnvilChunkStorage {
@Inject(method = "loadEntity", at = @At("HEAD"))
private void preventAsyncEntityLoad(CallbackInfo ci) {
if (!this.mainThreadExecutor.isOnThread()) {
throw new ConcurrentModificationException("Async entity load");
final ConcurrentModificationException e = new ConcurrentModificationException("Async entity load");
e.printStackTrace();
throw e;
}
}

@Inject(method = "unloadEntity", at = @At("HEAD"))
private void preventAsyncEntityUnload(CallbackInfo ci) {
if (!this.mainThreadExecutor.isOnThread()) {
throw new ConcurrentModificationException("Async entity unload");
final ConcurrentModificationException e = new ConcurrentModificationException("Async entity unload");
e.printStackTrace();
throw e;
}
}

Expand Down

0 comments on commit 3fcb0a0

Please sign in to comment.