From bf2dd64a4bf8190b9a388f60b80f2ac39570889f Mon Sep 17 00:00:00 2001 From: ElNounch Date: Fri, 9 Apr 2021 00:34:54 +0200 Subject: [PATCH] Fix GT-New-Horizons-Modpack#7789 - Game Over GUI buttons disabled if switching fullscreen --- .../core/HodgepodgeMixinPlugin.java | 4 +++ .../hodgepodge/core/LoadingConfig.java | 4 ++- .../fixGuiGameOver/gui/MixinGuiGameOver.java | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/mitchej123/hodgepodge/mixins/fixGuiGameOver/gui/MixinGuiGameOver.java diff --git a/src/main/java/com/mitchej123/hodgepodge/core/HodgepodgeMixinPlugin.java b/src/main/java/com/mitchej123/hodgepodge/core/HodgepodgeMixinPlugin.java index c8fc6482..73fdbe44 100644 --- a/src/main/java/com/mitchej123/hodgepodge/core/HodgepodgeMixinPlugin.java +++ b/src/main/java/com/mitchej123/hodgepodge/core/HodgepodgeMixinPlugin.java @@ -145,6 +145,10 @@ public enum MixinSets { () -> config.dropPickedLootOnDespawn, Collections.singletonList("dropPickedLootOnDespawn.MixinEntityLiving") ), + GAMEOVER_GUI_LOCKED_DISABLED("Game Over GUI buttons disabled if switching fullscreen Fix", + () -> config.fixGuiGameOver, + Collections.singletonList("fixGuiGameOver.MixinGuiGameOver") + ), WAKE_ANCHORS_ON_LOGIN("Wake up personal anchors on owner login", () -> config.installAnchorAlarm, "Railcraft_1.7.10", diff --git a/src/main/java/com/mitchej123/hodgepodge/core/LoadingConfig.java b/src/main/java/com/mitchej123/hodgepodge/core/LoadingConfig.java index 7f4a9147..b7b1e2a8 100644 --- a/src/main/java/com/mitchej123/hodgepodge/core/LoadingConfig.java +++ b/src/main/java/com/mitchej123/hodgepodge/core/LoadingConfig.java @@ -19,7 +19,8 @@ public class LoadingConfig { public boolean fixHungerOverhaul; public boolean removeUpdateChecks; public boolean preventPickupLoot; - public boolean dropPickedLootOnDespawn; + public boolean dropPickedLootOnDespawn; + public boolean fixGuiGameOver; public boolean installAnchorAlarm; // ASM public boolean pollutionAsm; @@ -44,6 +45,7 @@ public LoadingConfig(File file) { fixThaumcraftUnprotectedGetBlock = config.get("fixes", "fixThaumcraftUnprotectedGetBlock", true, "Various Thaumcraft unchecked getBlock() patches").getBoolean(); fixHungerOverhaul = config.get("fixes", "fixHungerOverhaul", true, "Fix hunger overhaul low stat effects").getBoolean(); removeUpdateChecks = config.get("fixes", "removeUpdateChecks", true, "Remove old/stale/outdated update checks.").getBoolean(); + fixGuiGameOver = config.get("fixes", "fixGuiGameOver", true, "Fix Game Over GUI buttons disabled if switching fullscreen").getBoolean(); installAnchorAlarm = config.get("tweaks", "installAnchorAlarm", true, "Wake up passive & personal anchors on player login").getBoolean(); preventPickupLoot = config.get("tweaks", "preventPickupLoot", true, "Prevent monsters from picking up loot.").getBoolean(); diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/fixGuiGameOver/gui/MixinGuiGameOver.java b/src/main/java/com/mitchej123/hodgepodge/mixins/fixGuiGameOver/gui/MixinGuiGameOver.java new file mode 100644 index 00000000..3f29030b --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/fixGuiGameOver/gui/MixinGuiGameOver.java @@ -0,0 +1,29 @@ +package com.mitchej123.hodgepodge.mixins.fixGuiGameOver; + +import net.minecraft.client.gui.GuiGameOver; + +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; + +@Mixin(GuiGameOver.class) +public class MixinGuiGameOver { + + // Number of ticks screen was open + @Shadow + private int field_146347_a; + + /** + * @author ElNounch + * @reason Fix Game Over GUI buttons disabled if switching fullscreen + */ + @Inject(method = "initGui", at = @At("HEAD")) + public void resetedInitGui(CallbackInfo ci) { + if (field_146347_a > 19) { + // Make sure buttons will be re-enabled next tick + field_146347_a = 19; + } + } +}