generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed not taking screenshot when disconnected by the server (#24)
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/minenash/seamless_loading_screen/mixin/ClientPlayNetworkHandlerMixin.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 |
---|---|---|
@@ -1,22 +1,48 @@ | ||
package com.minenash.seamless_loading_screen.mixin; | ||
|
||
import com.minenash.seamless_loading_screen.FinishQuit; | ||
import com.minenash.seamless_loading_screen.ScreenshotLoader; | ||
import com.minenash.seamless_loading_screen.SeamlessLoadingScreen; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.DisconnectedScreen; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.TitleScreen; | ||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.client.realms.gui.screen.DisconnectedRealmsScreen; | ||
import net.minecraft.client.realms.gui.screen.RealmsScreen; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.text.Text; | ||
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.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientPlayNetworkHandler.class) | ||
public class ClientPlayNetworkHandlerMixin { | ||
|
||
@Shadow @Final private Screen loginScreen; | ||
|
||
@Shadow @Final private static Text field_26620; | ||
|
||
@Redirect(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;joinWorld(Lnet/minecraft/client/world/ClientWorld;)V")) | ||
private void setChangeWorldJoinScreen(MinecraftClient client, ClientWorld world) { | ||
if (ScreenshotLoader.loaded) { | ||
SeamlessLoadingScreen.changeWorldJoinScreen = true; | ||
} | ||
client.joinWorld(world); | ||
} | ||
|
||
private boolean stopDisconnect = true; | ||
@Inject(method = "onDisconnected", at = @At("HEAD"), cancellable = true) | ||
private void onServerOrderedDisconnect(Text reason, CallbackInfo info) { | ||
if (stopDisconnect) { | ||
info.cancel(); | ||
FinishQuit.run((ClientPlayNetworkHandler) (Object) this, reason); | ||
} | ||
stopDisconnect = !stopDisconnect; | ||
} | ||
} |