Skip to content

Commit f3d5ba7

Browse files
committed
Restore the "Unbind Conflicting Key" option as a limited internal functionality
Fabric-only as well!
1 parent 8bca84f commit f3d5ba7

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

mod_common/src/main/java/page/langeweile/ok_zoomer/config/OkZoomerConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ public static final class TweaksConfig extends Section {
220220
@WidgetSize(Size.HALF)
221221
@Comment("Prints a random owo in the console when the game starts.")
222222
public final TrackedValue<Boolean> printOwoOnStart = this.value(true);
223+
224+
@WidgetSize(Size.FULL)
225+
@Comment("If enabled, the \"Save Toolbar Activator\" keybind will be unbound if there's a conflict with the zoom key.")
226+
public final TrackedValue<Boolean> unbindConflictingKey = this.value(true);
227+
223228
}
224229

225230
// TODO - What if we had a secret Debug section?

mod_common/src/main/java/page/langeweile/ok_zoomer/config/screen/OkZoomerConfigScreen.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ protected void init() {
8080
this.newValues.putIfAbsent(trackie, trackedValue.getRealValue());
8181

8282
if (trackedValue.value() instanceof Boolean) {
83+
if (trackedValue.equals(OkZoomerConfigManager.CONFIG.tweaks.unbindConflictingKey)) {
84+
continue;
85+
}
86+
8387
var button = CycleButton.onOffBuilder((Boolean) this.newValues.get(trackie))
8488
.withTooltip(value -> Tooltip.create(this.configTextUtils.getOptionTextTooltip(trackedValue)))
8589
.create(

mod_common/src/main/java/page/langeweile/ok_zoomer/events/ApplyLoadOnceOptionsEvent.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package page.langeweile.ok_zoomer.events;
22

3+
import com.mojang.blaze3d.platform.InputConstants;
4+
import net.minecraft.client.KeyMapping;
5+
import net.minecraft.client.Minecraft;
36
import page.langeweile.ok_zoomer.config.OkZoomerConfigManager;
4-
import page.langeweile.ok_zoomer.utils.OwoUtils;
7+
import page.langeweile.ok_zoomer.key_binds.ZoomKeyBinds;import page.langeweile.ok_zoomer.utils.OwoUtils;
8+
import page.langeweile.ok_zoomer.utils.ZoomUtils;
59

610
// The event that makes sure to load the config and puts any load-once options in effect if enabled through the config file
711
public class ApplyLoadOnceOptionsEvent {
@@ -11,4 +15,23 @@ public static void readyClient() {
1115
OwoUtils.printOwo();
1216
}
1317
}
18+
19+
// Made Fabric-exclusive since (Neo)Forge doesn't have this problem
20+
public static void readyClientFabric(Minecraft minecraft) {
21+
// This handles the unbinding of the "Save Toolbar Activator" key
22+
if (OkZoomerConfigManager.CONFIG.tweaks.unbindConflictingKey.value()) {
23+
if (ZoomKeyBinds.ZOOM_KEY.isDefault()) {
24+
if (minecraft.options.keySaveHotbarActivator.isDefault()) {
25+
ZoomUtils.LOGGER.info("[Ok Zoomer] The \"Save Toolbar Activator\" keybind was occupying C! Unbinding... This process won't be repeated until set manually in the config file.");
26+
minecraft.options.keySaveHotbarActivator.setKey(InputConstants.UNKNOWN);
27+
minecraft.options.save();
28+
KeyMapping.resetMapping();
29+
} else {
30+
ZoomUtils.LOGGER.info("[Ok Zoomer] No conflicts with the \"Save Toolbar Activator\" keybind were found!");
31+
}
32+
}
33+
34+
OkZoomerConfigManager.CONFIG.tweaks.unbindConflictingKey.setValue(false, true);
35+
}
36+
}
1437
}

mod_fabric/src/main/java/page/langeweile/ok_zoomer/OkZoomerClientMod.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package page.langeweile.ok_zoomer;
22

3+
import com.mojang.datafixers.kinds.App;
34
import net.fabricmc.api.ClientModInitializer;
45
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
56
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
@@ -30,7 +31,10 @@ public void onInitializeClient() {
3031
// Register events without entrypoints aughhhhhhhh
3132
ClientTickEvents.START_CLIENT_TICK.register(ManageZoomEvent::startClientTick);
3233
ClientTickEvents.START_CLIENT_TICK.register(client -> ManageExtraKeysEvent.startClientTick());
33-
ClientLifecycleEvents.CLIENT_STARTED.register(client -> ApplyLoadOnceOptionsEvent.readyClient());
34+
ClientLifecycleEvents.CLIENT_STARTED.register(client -> {
35+
ApplyLoadOnceOptionsEvent.readyClient();
36+
ApplyLoadOnceOptionsEvent.readyClientFabric(client);
37+
});
3438
ClientTickEvents.END_CLIENT_TICK.register(OpenScreenEvent::endClientTick);
3539
ClientCommandRegistrationCallback.EVENT.register(RegisterCommands::registerCommands);
3640

0 commit comments

Comments
 (0)