Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
08189b9
chore: move CigaretteScreen instance into Cigarette pkg
UndercoverGoose Oct 3, 2025
4ebbd39
create keybinding helper
UndercoverGoose Oct 3, 2025
92b9185
create Minecraft Keyboard mixin
UndercoverGoose Oct 3, 2025
63d944f
remove KeyBinding mod initializer
UndercoverGoose Oct 3, 2025
c59418e
add binding and press checks
UndercoverGoose Oct 3, 2025
3aa146f
add input blocking methods
UndercoverGoose Oct 3, 2025
76ef306
add mouse blocking enabled by default when keys are blocked
UndercoverGoose Oct 3, 2025
fe99bdf
create keybind wrappers and InputBlocker class
UndercoverGoose Oct 4, 2025
16d039d
use new wrappers
UndercoverGoose Oct 4, 2025
818e623
add mouse blocking
UndercoverGoose Oct 4, 2025
df44459
add method to trigger virtual key press
UndercoverGoose Oct 4, 2025
ef9ff9f
fix: wrapped keybinds do not receive events
UndercoverGoose Oct 4, 2025
510e3f5
properly support mouse events (no scrolling)
UndercoverGoose Oct 4, 2025
e85f501
add virtual key holding and releasing
UndercoverGoose Oct 4, 2025
c603665
fix: mouse virtual state desyncing from physical state after unblocking
UndercoverGoose Oct 4, 2025
6731f9d
create tick helper to schedule events to occur in X ticks
UndercoverGoose Oct 7, 2025
ccd257f
add hold/release for X ticks functionality
UndercoverGoose Oct 7, 2025
2a28257
chore: add javadocs to TickHelper
UndercoverGoose Oct 8, 2025
3d8fb4a
chore: finish javadocs in KeybindHelper
UndercoverGoose Oct 8, 2025
f0feeed
chore: rename keys to make sense
UndercoverGoose Oct 8, 2025
4f7aa60
add most other native keybinds
UndercoverGoose Oct 8, 2025
3c68f3e
chore: finish javadocs in MinecraftKeybind
UndercoverGoose Oct 8, 2025
778ce2e
remove asMouse in favor of a constructor arg
UndercoverGoose Oct 8, 2025
7f4c4d7
chore: finish javadocs in VirtualKeybind
UndercoverGoose Oct 8, 2025
ff2d0ce
fix: missing checks on whether keybind is a mouse binding when compar…
UndercoverGoose Oct 8, 2025
4ef6392
chore: add javadocs to InputBlocker
UndercoverGoose Oct 8, 2025
e0eb92f
add methods for setting the default and current bounded key
UndercoverGoose Oct 8, 2025
ad862be
add registering method for virtual keybinds
UndercoverGoose Oct 8, 2025
2cc9d6e
update KeybindWidget to use VirtualKeybind
UndercoverGoose Oct 8, 2025
96c2bea
fix: pressing escape to unbind keybind closes GUI afterwards
UndercoverGoose Oct 8, 2025
577a69d
fix: keybinds loaded from config do not work
UndercoverGoose Oct 8, 2025
64e1a85
remove KeyBindingAccessor and KeyboardInputMixin and update modules t…
UndercoverGoose Oct 8, 2025
9bfd16e
fix: virtual keybinds trigger inside of GUIs
UndercoverGoose Oct 8, 2025
cb1bcd5
fix crash when attempting to bridge on a mode that is disabled
UndercoverGoose Oct 10, 2025
f10b022
remove restriction on keys that can be bound
UndercoverGoose Oct 10, 2025
2ddda74
fix virtual keybinds queueing events when modules are disabled
UndercoverGoose Oct 10, 2025
52fc1c1
Merge branch 'main' into chore/keybind
UndercoverGoose Oct 10, 2025
e12e133
fix: mouse events duplicate when in GUIs
UndercoverGoose Oct 10, 2025
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
2 changes: 2 additions & 0 deletions src/main/java/dev/cigarette/Cigarette.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.cigarette.config.Config;
import dev.cigarette.config.FileSystem;
import dev.cigarette.events.Events;
import dev.cigarette.gui.CigaretteScreen;
import dev.cigarette.gui.hud.notification.NotificationDisplay;
import dev.cigarette.lib.ChatLogger;
import net.fabricmc.api.ModInitializer;
Expand Down Expand Up @@ -37,6 +38,7 @@ public class Cigarette implements ModInitializer {
public static final Identifier LOGO_IDENTIFIER = Identifier.of("cigarette", "icon.png");
public static final boolean IN_DEV_ENVIRONMENT = FabricLoader.getInstance().isDevelopmentEnvironment();
public static Config CONFIG = Config.construct();
public static CigaretteScreen SCREEN = new CigaretteScreen();
public static BedwarsAgent BEDWARS_AGENT = new BedwarsAgent(DevWidget.bedwarsAgent);
public static MurderMysteryAgent MURDER_MYSTERY_AGENT = new MurderMysteryAgent(DevWidget.murderMysteryAgent);
public static ZombiesAgent ZOMBIES_AGENT = new ZombiesAgent(DevWidget.zombiesAgent);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/cigarette/gui/CigaretteScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class CigaretteScreen extends Screen {
*/
public static @Nullable KeybindWidget bindingKey = null;

protected CigaretteScreen() {
public CigaretteScreen() {
super(Text.literal("Cigarette Client"));
}

Expand Down
34 changes: 0 additions & 34 deletions src/main/java/dev/cigarette/gui/KeyBinding.java

This file was deleted.

47 changes: 14 additions & 33 deletions src/main/java/dev/cigarette/gui/widget/KeybindWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@

import dev.cigarette.Cigarette;
import dev.cigarette.gui.CigaretteScreen;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import dev.cigarette.helper.KeybindHelper;
import dev.cigarette.helper.keybind.VirtualKeybind;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;

import java.util.Objects;
import java.util.UUID;
import java.util.function.Consumer;

/**
* A widget that lets the user bind a key.
*/
public class KeybindWidget extends BaseWidget<Integer> {
/**
* The internal Minecraft KeyBinding.
*/
private final KeyBinding keyBinding;
/**
* The KeyBindings actual key for rendering and configuration.
*/
private InputUtil.Key utilKey;
private final VirtualKeybind keyBinding = new VirtualKeybind(GLFW.GLFW_KEY_UNKNOWN);
private InputUtil.Key utilKey = InputUtil.UNKNOWN_KEY;

/**
* Creates a widget that stores a keybind and allows it to be configured.
Expand All @@ -37,9 +30,7 @@ public class KeybindWidget extends BaseWidget<Integer> {
*/
public KeybindWidget(String message, @Nullable String tooltip) {
super(message, tooltip);
this.utilKey = InputUtil.UNKNOWN_KEY;
this.keyBinding = new KeyBinding(UUID.randomUUID().toString(), GLFW.GLFW_KEY_UNKNOWN, "cigarette.null");
KeyBindingHelper.registerKeyBinding(this.keyBinding);
KeybindHelper.registerVirtualKey(this.keyBinding);
}

/**
Expand All @@ -50,26 +41,19 @@ public KeybindWidget(String message, @Nullable String tooltip) {
*/
public KeybindWidget withDefaultKey(int key) {
utilKey = InputUtil.fromKeyCode(key, 0);
keyBinding.setBoundKey(utilKey);
keyBinding.setDefaultKey(key);
keyBinding.setKey(key);
super.withDefault(key);
return this;
}

/**
* Update the stored key of this widget from an input event.
*
* @param key The new key to set to this widget
*/
public void setBoundKey(@Nullable InputUtil.Key key) {
utilKey = key == null ? InputUtil.UNKNOWN_KEY : key;
keyBinding.setBoundKey(utilKey);
this.setRawState(utilKey.getCode());
public void setBoundKey(int key) {
utilKey = key == GLFW.GLFW_KEY_UNKNOWN ? InputUtil.UNKNOWN_KEY : InputUtil.fromKeyCode(key, 0);
keyBinding.setKey(key);
this.setRawState(key);
}

/**
* {@return the internal Minecraft KeyBinding}
*/
public KeyBinding getKeybind() {
public VirtualKeybind getKeybind() {
return this.keyBinding;
}

Expand Down Expand Up @@ -143,12 +127,9 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (!isBinding()) return false;
if (keyCode == GLFW.GLFW_KEY_ESCAPE || keyCode == GLFW.GLFW_KEY_RIGHT_SHIFT) {
this.setBoundKey(null);
this.setBoundKey(GLFW.GLFW_KEY_UNKNOWN);
} else {
InputUtil.Key key = InputUtil.fromKeyCode(keyCode, scanCode);
String keyName = key.getLocalizedText().getLiteralString();
if (keyName == null) return true;
this.setBoundKey(key);
this.setBoundKey(keyCode);
}
clearBinding();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import dev.cigarette.module.BaseModule;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.option.KeyBinding;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;

Expand Down Expand Up @@ -44,13 +43,6 @@ public ToggleKeybindWidget withDefaultKey(int keyCode) {
return this;
}

/**
* {@return the internal Minecraft KeyBinding}
*/
public KeyBinding getKeybind() {
return this.widget.getKeybind();
}

/**
* Generator for modules using this as a top-level widget.
*
Expand Down
Loading