-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the singleplayer F3 screen threadsafe by disallowing level access
- Loading branch information
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
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
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
51 changes: 51 additions & 0 deletions
51
src/main/java/no2/worldthreader/mixin/threading_compatibility/DebugScreenOverlayMixin.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,51 @@ | ||
package no2.worldthreader.mixin.threading_compatibility; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.components.DebugScreenOverlay; | ||
import net.minecraft.client.server.IntegratedServer; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(DebugScreenOverlay.class) | ||
public class DebugScreenOverlayMixin { | ||
|
||
@Shadow | ||
@Final | ||
private Minecraft minecraft; | ||
|
||
/** | ||
* @author 2No2Name | ||
* @reason That's not threadsafe. So don't do it. | ||
*/ | ||
@Overwrite | ||
@Nullable | ||
private ServerLevel getServerLevel() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @author 2No2Name | ||
* @reason That's not threadsafe. So don't do it. | ||
*/ | ||
@Overwrite | ||
private Level getLevel() { | ||
return this.minecraft.level; | ||
} | ||
|
||
@Redirect( | ||
method = {"getGameInformation()Ljava/util/List;", "drawGameInformation(Lnet/minecraft/client/gui/GuiGraphics;)V"}, | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/Minecraft;getSingleplayerServer()Lnet/minecraft/client/server/IntegratedServer;") | ||
) | ||
private IntegratedServer avoidOffthreadAccess(Minecraft instance) { | ||
return null; | ||
} | ||
} |
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