-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: check for async entity loading and unloading
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...me/fixes/general/threading_issues/mixin/asynccatchers/MixinThreadedAnvilChunkStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.ishland.c2me.fixes.general.threading_issues.mixin.asynccatchers; | ||
|
||
import net.minecraft.server.world.ThreadedAnvilChunkStorage; | ||
import net.minecraft.util.thread.ThreadExecutor; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.ConcurrentModificationException; | ||
|
||
@Mixin(ThreadedAnvilChunkStorage.class) | ||
public class MixinThreadedAnvilChunkStorage { | ||
|
||
@Shadow @Final private ThreadExecutor<Runnable> mainThreadExecutor; | ||
|
||
@Inject(method = "loadEntity", at = @At("HEAD")) | ||
private void preventAsyncEntityLoad(CallbackInfo ci) { | ||
if (!this.mainThreadExecutor.isOnThread()) { | ||
throw new ConcurrentModificationException("Async entity load"); | ||
} | ||
} | ||
|
||
@Inject(method = "unloadEntity", at = @At("HEAD")) | ||
private void preventAsyncEntityUnload(CallbackInfo ci) { | ||
if (!this.mainThreadExecutor.isOnThread()) { | ||
throw new ConcurrentModificationException("Async entity unload"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters