Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nobreakthatblock #65

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/club/sk1er/patcher/Patcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/club/sk1er/patcher/util/pause/PauseHandler.java
Original file line number Diff line number Diff line change
@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need the check here too

Copy link
Author

@MicrocontrollersDev MicrocontrollersDev Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what check? if you mean gui check you cant move your mouse (pitch/yaw) while in a gui anyways so dont see why that applies here

event.setCanceled(true);
Minecraft.getMinecraft().mouseHelper.mouseXYChange();
}
}
}
Loading