diff --git a/README.md b/README.md index c17e9116..2797742e 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,9 @@ This work, "PolyPatcher", is adapted from ["Patcher"](https://sk1er.club/mods/pa - **Startup Notification** - Notify how long the game took to start. *default - **Clean Main Menu** - Remove the Realms button on the main menu as it's useless on 1.8.9. *default - **Open to LAN Replacement** - Modify the Open to LAN button to either redirect to the server list or be removed. -- **Smart Disconnect -** Choose between disconnecting or relogging when clicking the disconnect button. (Only works on multiplayer servers) +- **Smart Disconnect** - Choose between disconnecting or relogging when clicking the disconnect button. (Only works on multiplayer servers) +- **Confirm Quit** - Prevent closing the game through the Quit Game button without confirmation. +- **Don't Click into GUIs** *(not in original)* - When tabbed out, don't allow clicks in GUIs to register when tabbing back in. - **Image Preview** - Preview image links when hovering over a supported URL. Press shift to use fullscreen and Control to render in native image resolution. (Currently supported: Imgur, Discord, Badlion screenshots) - **Image Preview Width** - The % of screen width to be used for image preview. - **Inventory Position** - Stop potion effects from shifting your inventory to the right. *default @@ -260,6 +262,8 @@ This work, "PolyPatcher", is adapted from ["Patcher"](https://sk1er.club/mods/pa - Add "Exclude Cacti from 1.12 Boxes" - Add "Improved Skin Rendering" - Add "Add Background to Book GUI" +- Add "Don't Click into GUIs" +- Add NoBreakThatBlock functionality - Replace "Remove Container Background" with "Container Background Opacity" - Replace "Nausea Effect" toggle to "Distortion Effects" slider - Split "Disable Grounded Arrows" into two settings ("Disable Unpickable Grounded Arrows" and "Disable All Grounded Arrows") @@ -299,6 +303,7 @@ This list may not always be up-to-date. To view an updated list, click [here](ht - ~~**Clean View**~~ Replaced by [OverflowParticles](https://modrinth.com/mod/overflowparticles) instead - **MemoryFix** - **MouseDelayFix** +- **NoBreakThatBlock** *(not in original)* - **NoCloseMyChat** - **Vanilla Enhancements** - **PortalInputFix** diff --git a/src/main/java/club/sk1er/patcher/Patcher.java b/src/main/java/club/sk1er/patcher/Patcher.java index bc106663..db1862dd 100644 --- a/src/main/java/club/sk1er/patcher/Patcher.java +++ b/src/main/java/club/sk1er/patcher/Patcher.java @@ -31,6 +31,7 @@ import club.sk1er.patcher.util.keybind.KeybindDropModifier; import club.sk1er.patcher.util.keybind.MousePerspectiveKeybindHandler; import club.sk1er.patcher.util.keybind.linux.LinuxKeybindFix; +import club.sk1er.patcher.util.pause.PauseHandler; import club.sk1er.patcher.util.screenshot.AsyncScreenshots; import club.sk1er.patcher.util.status.ProtocolVersionDetector; import club.sk1er.patcher.util.world.SavesWatcher; @@ -135,7 +136,8 @@ public void onInit(FMLInitializationEvent event) { new TitleFix(), new LinuxKeybindFix(), new MetricsRenderer(), new HUDCaching(), new EntityRendererHook(), MinecraftHook.INSTANCE, ScreenshotPreview.INSTANCE, - new MousePerspectiveKeybindHandler() + new MousePerspectiveKeybindHandler(), + new PauseHandler() ); checkLogs(); diff --git a/src/main/java/club/sk1er/patcher/config/PatcherConfig.java b/src/main/java/club/sk1er/patcher/config/PatcherConfig.java index eec8c4a6..9b054363 100644 --- a/src/main/java/club/sk1er/patcher/config/PatcherConfig.java +++ b/src/main/java/club/sk1er/patcher/config/PatcherConfig.java @@ -1212,6 +1212,13 @@ public static int getInventoryScale() { ) public static boolean confirmQuit; + @Switch( + name = "Don't Click into GUIs", + description = "When tabbed out, don't allow clicks in GUIs to register when tabbing back in.", + category = "Screens", subcategory = "General" + ) + public static boolean dontClickIntoGui; + // SCREENSHOTS @Info( diff --git a/src/main/java/club/sk1er/patcher/util/pause/PauseHandler.java b/src/main/java/club/sk1er/patcher/util/pause/PauseHandler.java new file mode 100644 index 00000000..2e4d6b36 --- /dev/null +++ b/src/main/java/club/sk1er/patcher/util/pause/PauseHandler.java @@ -0,0 +1,46 @@ +package club.sk1er.patcher.util.pause; + +import club.sk1er.patcher.config.PatcherConfig; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.Display; + +public class PauseHandler { + private int ticks; + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (!Display.isActive()) { + ticks = 2; + } else if (ticks > 0) { + ticks--; + } + } + + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent event) { + if (event.gui instanceof GuiMainMenu) { + ticks = 2; + } + } + + @SubscribeEvent + public void onGuiMouse(GuiScreenEvent.MouseInputEvent.Pre event) { + if (ticks > 0 && (event.gui != null && PatcherConfig.dontClickIntoGui)) { + event.setCanceled(true); + } + } + + @SubscribeEvent + public void onGameMouse(MouseEvent event) { + if (ticks > 0) { + event.setCanceled(true); + Minecraft.getMinecraft().mouseHelper.mouseXYChange(); + } + } +}