|
1 | 1 | package dev.frydae.emcutils.mixins;
|
2 | 2 |
|
3 | 3 | import net.minecraft.client.MinecraftClient;
|
4 |
| -import net.minecraft.client.gui.screen.DeathScreen; |
5 | 4 | import net.minecraft.client.gui.screen.Screen;
|
6 |
| -import net.minecraft.client.gui.screen.TitleScreen; |
7 | 5 | import net.minecraft.client.option.KeyBinding;
|
8 |
| -import net.minecraft.client.sound.SoundManager; |
9 | 6 | import net.minecraft.client.util.Window;
|
10 |
| -import net.minecraft.text.Text; |
11 | 7 | import org.jetbrains.annotations.Nullable;
|
| 8 | +import org.spongepowered.asm.mixin.Final; |
12 | 9 | import org.spongepowered.asm.mixin.Mixin;
|
13 | 10 | import org.spongepowered.asm.mixin.Shadow;
|
14 | 11 | import org.spongepowered.asm.mixin.injection.At;
|
15 | 12 | import org.spongepowered.asm.mixin.injection.Inject;
|
16 | 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
17 |
| -//import dev.frydae.emcutils.utils.Log; |
18 | 14 | import dev.frydae.emcutils.features.vaultButtons.VaultScreen;
|
19 | 15 |
|
20 | 16 | @Mixin(MinecraftClient.class)
|
21 | 17 | public class MinecraftClientMixin {
|
22 |
| - @Shadow |
23 |
| - private SoundManager soundManager; |
| 18 | + @Final |
24 | 19 | @Shadow
|
25 | 20 | private Window window;
|
26 | 21 |
|
27 | 22 | @Inject(at = @At("INVOKE"), method = "openScreen", cancellable = true)
|
28 | 23 | public void onOpenScreen(@Nullable Screen screen, CallbackInfo ci) {
|
29 |
| - //Log.info("MinecraftClient openScreen called!"); |
30 | 24 | if (!(screen instanceof VaultScreen)) {
|
31 |
| - //Log.info("openScreen NOT for VaultScreen"); |
32 | 25 | return;
|
33 | 26 | }
|
34 | 27 |
|
35 |
| - //Log.info("openScreen just for VaultScreen"); |
36 | 28 | MinecraftClient mc = (MinecraftClient) (Object) this;
|
37 | 29 |
|
38 | 30 | if (mc.currentScreen != null) {
|
39 | 31 | mc.currentScreen.removed();
|
40 | 32 | }
|
41 | 33 |
|
42 |
| - if (screen == null && mc.world == null) { |
43 |
| - screen = new TitleScreen(); |
44 |
| - } else if (screen == null && mc.player.isDead()) { |
45 |
| - if (mc.player.showsDeathScreen()) { |
46 |
| - screen = new DeathScreen((Text)null, mc.world.getLevelProperties().isHardcore()); |
47 |
| - } else { |
48 |
| - mc.player.requestRespawn(); |
49 |
| - } |
50 |
| - } |
51 |
| - |
52 |
| - mc.currentScreen = (Screen) screen; |
53 |
| - if (screen != null) { |
54 |
| - mc.mouse.unlockCursor(); |
55 |
| - KeyBinding.unpressAll(); |
56 |
| - ((Screen)screen).init(mc, window.getScaledWidth(), window.getScaledHeight()); |
57 |
| - mc.skipGameRender = false; |
58 |
| - } else { |
59 |
| - soundManager.resumeAll(); |
60 |
| - mc.mouse.lockCursor(); |
61 |
| - } |
| 34 | + mc.currentScreen = screen; |
| 35 | + mc.mouse.unlockCursor(); |
| 36 | + KeyBinding.unpressAll(); |
| 37 | + screen.init(mc, window.getScaledWidth(), window.getScaledHeight()); |
| 38 | + mc.skipGameRender = false; |
62 | 39 |
|
63 | 40 | mc.updateWindowTitle();
|
64 | 41 | ci.cancel();
|
|
0 commit comments