From abc98ba56b300f1c590e2944c603a8d4cd0820a1 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Tue, 12 May 2020 22:18:03 +0100 Subject: [PATCH] Fix vanilla screens escape key not matching done button behavior (#6682) --- .../RealmsGenericErrorScreen.java.patch | 18 ++++++++++++++++++ .../gui/screen/MultiplayerScreen.java.patch | 14 ++++++++++++++ .../client/gui/screen/OptionsScreen.java.patch | 15 +++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch create mode 100644 patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch create mode 100644 patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch diff --git a/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch new file mode 100644 index 000000000..0735fd2a7 --- /dev/null +++ b/patches/minecraft/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java.patch @@ -0,0 +1,18 @@ +--- a/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java ++++ b/com/mojang/realmsclient/gui/screens/RealmsGenericErrorScreen.java +@@ -64,6 +64,15 @@ + super.tick(); + } + ++ @Override ++ public boolean keyPressed(int key, int scanCode, int modifiers) { ++ if (key == org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) { ++ Realms.setScreen(this.field_224228_a); ++ return true; ++ } ++ return super.keyPressed(key, scanCode, modifiers); ++ } ++ + public void render(int p_render_1_, int p_render_2_, float p_render_3_) { + this.renderBackground(); + this.drawCenteredString(this.field_224229_b, this.width() / 2, 80, 16777215); diff --git a/patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch new file mode 100644 index 000000000..19b3ca092 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screen/MultiplayerScreen.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/client/gui/screen/MultiplayerScreen.java ++++ b/net/minecraft/client/gui/screen/MultiplayerScreen.java +@@ -241,6 +241,11 @@ + + } + ++ @Override ++ public void onClose() { ++ this.minecraft.func_147108_a(this.field_146798_g); ++ } ++ + public ServerPinger func_146789_i() { + return this.field_146797_f; + } diff --git a/patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch new file mode 100644 index 000000000..7049508ea --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screen/OptionsScreen.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/client/gui/screen/OptionsScreen.java ++++ b/net/minecraft/client/gui/screen/OptionsScreen.java +@@ -118,4 +118,12 @@ + this.drawCenteredString(this.font, this.title.func_150254_d(), this.width / 2, 15, 16777215); + super.render(p_render_1_, p_render_2_, p_render_3_); + } ++ ++ @Override ++ public void onClose() { ++ // We need to consider 2 potential parent screens here: ++ // 1. From the main menu, in which case display the main menu ++ // 2. From the pause menu, in which case exit back to game ++ this.minecraft.func_147108_a(this.field_146441_g instanceof IngameMenuScreen ? null : this.field_146441_g); ++ } + }