### Create and Manage Boolean Config Options Source: https://context7.com/sakura-ryoko/malilib/llms.txt Demonstrates creating ConfigBoolean instances with default values and comments, and how to get, set, toggle, and manage their state. ```java import fi.dy.masa.malilib.config.options.ConfigBoolean; // Create a boolean config with name and default value ConfigBoolean enableFeature = new ConfigBoolean("enableFeature", true); // Create with comment for GUI tooltip ConfigBoolean debugMode = new ConfigBoolean("debugMode", false, "Enable debug logging"); // Create with pretty name for display ConfigBoolean showOverlay = new ConfigBoolean("showOverlay", true, "Show the HUD overlay", "Show Overlay"); // Get and set values boolean isEnabled = enableFeature.getBooleanValue(); enableFeature.setBooleanValue(false); // Check if modified from default if (enableFeature.isModified()) { enableFeature.resetToDefault(); } // Toggle the value enableFeature.toggleBooleanValue(); // Get JSON representation for saving JsonElement json = enableFeature.getAsJsonElement(); // Load from JSON enableFeature.setValueFromJsonElement(json); ``` -------------------------------- ### Get Hotkey Display String Source: https://context7.com/sakura-ryoko/malilib/llms.txt Retrieves a user-friendly string representation of the hotkey combination for display in GUIs. Shows the keybind as it's configured. ```java // Get display string for GUI String displayStr = openMenu.getKeybind().getKeysDisplayString(); // "M" or "Ctrl + Shift + S" ``` -------------------------------- ### Get Boolean Value Source: https://context7.com/sakura-ryoko/malilib/llms.txt Retrieves the current boolean state of a ConfigBooleanHotkeyed option. Use to check if the feature is currently enabled. ```java // Get boolean value boolean isEnabled = flyMode.getBooleanValue(); ``` -------------------------------- ### Get Color as Integer Source: https://context7.com/sakura-ryoko/malilib/llms.txt Obtains the color value as an integer, compatible with Minecraft's rendering system. Returns the ARGB integer representation. ```java // Get as integer for Minecraft rendering int colorInt = highlightColor.getIntegerValue(); // 0xFF00FF00 ``` -------------------------------- ### Access Boolean Hotkey Keybind Source: https://context7.com/sakura-ryoko/malilib/llms.txt Gets the string representation of the hotkey associated with a ConfigBooleanHotkeyed option. Useful for displaying the keybind in tooltips or settings. ```java // Access the keybind String hotkey = flyMode.getKeybind().getStringValue(); // "F" ``` -------------------------------- ### Get Current Keybind Keys Source: https://context7.com/sakura-ryoko/malilib/llms.txt Retrieves a list of the integer key codes that currently make up the keybind. Useful for debugging or displaying the active key combination. ```java // Get current keys List keys = keybind.getKeys(); // [KEY_LEFT_ALT, KEY_Z] ``` -------------------------------- ### Get Color as Color4f Source: https://context7.com/sakura-ryoko/malilib/llms.txt Retrieves the configured color value as a Color4f object, suitable for use in rendering pipelines. Provides RGBA float values between 0.0 and 1.0. ```java // Get color as Color4f for rendering Color4f color = highlightColor.getColor(); float r = color.r; // 0.0 - 1.0 float g = color.g; float b = color.b; float a = color.a; ``` -------------------------------- ### Create and Manage Integer Config Options with Ranges Source: https://context7.com/sakura-ryoko/malilib/llms.txt Shows how to create ConfigInteger options, including setting min/max bounds and enabling slider support for GUI representation. ```java import fi.dy.masa.malilib.config.options.ConfigInteger; // Simple integer config ConfigInteger timeout = new ConfigInteger("timeout", 60); // Integer with comment ConfigInteger maxItems = new ConfigInteger("maxItems", 100, "Maximum items to display"); // Integer with min/max bounds ConfigInteger renderDistance = new ConfigInteger("renderDistance", 16, 2, 32); // Integer with slider enabled in GUI ConfigInteger brightness = new ConfigInteger("brightness", 50, 0, 100, true, "Brightness level (0-100)"); // Get and set values int value = renderDistance.getIntegerValue(); renderDistance.setIntegerValue(24); // Get bounds int min = renderDistance.getMinIntegerValue(); // 2 int max = renderDistance.getMaxIntegerValue(); // 32 // Toggle slider mode if (brightness.shouldUseSlider()) { brightness.toggleUseSlider(); } ``` -------------------------------- ### Create and Manage String Config Options Source: https://context7.com/sakura-ryoko/malilib/llms.txt Illustrates the creation and management of ConfigString options, including setting values, retrieving previous values, and resetting to default. ```java import fi.dy.masa.malilib.config.options.ConfigString; // Create string config ConfigString playerName = new ConfigString("playerName", "Steve"); // With comment ConfigString serverAddress = new ConfigString("serverAddress", "localhost", "Server IP address"); // Get and set values String name = playerName.getStringValue(); playerName.setStringValue("Alex"); // Check previous value (useful for change callbacks) String lastValue = playerName.getLastStringValue(); // Reset to default playerName.resetToDefault(); ``` -------------------------------- ### Create Custom GUI Screen Source: https://context7.com/sakura-ryoko/malilib/llms.txt Extend GuiBase to create custom GUI screens. Use initGui to add widgets like labels, buttons, and text fields. Override drawContents for custom drawing. ```java import fi.dy.masa.malilib.gui.GuiBase; import fi.dy.masa.malilib.gui.button.ButtonGeneric; import fi.dy.masa.malilib.gui.widgets.WidgetLabel; import fi.dy.masa.malilib.render.GuiContext; public class MyCustomGui extends GuiBase { public MyCustomGui() { this.title = "My Custom GUI"; } @Override public void initGui() { super.initGui(); int x = 20; int y = 30; // Add a label this.addLabel(x, y, -1, 12, 0xFFFFFFFF, "Welcome to My GUI"); y += 20; // Add a button with action ButtonGeneric button = new ButtonGeneric(x, y, 100, 20, "Click Me"); this.addButton(button, (btn, mouseButton) -> { // Button clicked this.addGuiMessage(MessageType.INFO, 3000, "Button was clicked!"); }); y += 25; // Add a text field GuiTextFieldGeneric textField = new GuiTextFieldGeneric(x, y, 150, 18, this.font); textField.setText("Default text"); this.addTextField(textField, (field) -> { // Text changed System.out.println("New text: " + field.getText()); }); } @Override protected void drawContents(GuiContext ctx, int mouseX, int mouseY, float partialTicks) { // Custom drawing this.drawString(ctx, "Status: Active", 20, 100, 0xFF00FF00); } // Open the GUI public static void open() { GuiBase.openGui(new MyCustomGui()); } } ``` -------------------------------- ### Create Keybind from Storage String Source: https://context7.com/sakura-ryoko/malilib/llms.txt Instantiates a KeybindMulti object from its string representation, which includes key codes and settings. Use when loading keybinds from configuration files. ```java import fi.dy.masa.malilib.hotkeys.KeybindMulti; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.hotkeys.IKeybind; // Create keybind from storage string IKeybind keybind = KeybindMulti.fromStorageString("LEFT_CONTROL,S", KeybindSettings.DEFAULT); ``` -------------------------------- ### Configure Keybind Behavior with KeybindSettings Source: https://context7.com/sakura-ryoko/malilib/llms.txt Use predefined or custom settings to control when and how keybinds activate. Settings include context (in-game/GUI), activation trigger, and exclusivity. ```java import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.hotkeys.KeybindSettings.Context; import fi.dy.masa.malilib.hotkeys.KeyAction; // Use predefined settings KeybindSettings defaultSettings = KeybindSettings.DEFAULT; // In-game, on press KeybindSettings releaseSettings = KeybindSettings.RELEASE; // In-game, on release KeybindSettings guiSettings = KeybindSettings.GUI; // GUI only KeybindSettings exclusiveSettings = KeybindSettings.EXCLUSIVE; // Only one can trigger KeybindSettings modifierSettings = KeybindSettings.MODIFIER_INGAME; // For modifier keys // Create custom settings KeybindSettings customSettings = KeybindSettings.create( Context.ANY, // INGAME, GUI, or ANY KeyAction.BOTH, // PRESS, RELEASE, or BOTH true, // allowExtraKeys - other keys can be held false, // orderSensitive - key order doesn't matter true, // exclusive - prevents other keybinds from triggering true, // cancel - cancel vanilla key processing false // allowEmpty - allow empty keybind ); // Query settings Context context = customSettings.getContext(); KeyAction activateOn = customSettings.getActivateOn(); boolean allowsExtra = customSettings.getAllowExtraKeys(); boolean isExclusive = customSettings.isExclusive(); boolean shouldCancel = customSettings.shouldCancel(); // Serialize to JSON JsonObject json = customSettings.toJson(); // Deserialize from JSON KeybindSettings loaded = KeybindSettings.fromJson(json); ``` -------------------------------- ### Create Hotkey with Custom Settings Source: https://context7.com/sakura-ryoko/malilib/llms.txt Configures a hotkey with specific activation settings like activating on both press and release. Use for fine-grained control over hotkey behavior. ```java import fi.dy.masa.malilib.config.options.ConfigHotkey; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.hotkeys.IHotkeyCallback; import fi.dy.masa.malilib.hotkeys.KeyAction; // Hotkey with custom settings ConfigHotkey toggleFeature = new ConfigHotkey("toggleFeature", "G", KeybindSettings.INGAME_BOTH, // Activate on both press and release "Toggle feature on/off"); ``` -------------------------------- ### Create Mod Configuration GUI Source: https://context7.com/sakura-ryoko/malilib/llms.txt Use GuiModConfigs to create a configuration screen for your mod's settings. You can provide a list of configs directly or use ConfigOptionWrapper for more control. ```java import fi.dy.masa.malilib.config.gui.GuiModConfigs; import fi.dy.masa.malilib.config.gui.ConfigOptionWrapper; import fi.dy.masa.malilib.config.IConfigBase; // Create config GUI with list of configs public class MyModConfigGui extends GuiModConfigs { public MyModConfigGui() { super("mymodid", MyModConfigs.ALL_OPTIONS, "mymod.gui.title.config"); } } // Or with ConfigOptionWrapper for more control public class AdvancedConfigGui extends GuiModConfigs { public AdvancedConfigGui() { super("mymodid", ConfigOptionWrapper.createFor(MyModConfigs.ALL_OPTIONS), false, "mymod.gui.title.config" ); } @Override protected int getBrowserHeight() { return this.height - 80; // Custom height } } // Open config GUI GuiBase.openGui(new MyModConfigGui()); ``` -------------------------------- ### Serialize and Deserialize Configurations with ConfigUtils Source: https://context7.com/sakura-ryoko/malilib/llms.txt Use ConfigUtils to read and write configuration lists and hotkeys to JSON files. Ensure the file path is resolved via FileUtils before performing I/O operations. ```java import fi.dy.masa.malilib.config.ConfigUtils; import fi.dy.masa.malilib.config.IConfigBase; import fi.dy.masa.malilib.hotkeys.IHotkey; import com.google.gson.JsonObject; // Define your config options List generalOptions = ImmutableList.of( new ConfigBoolean("enabled", true), new ConfigInteger("amount", 10, 1, 100), new ConfigString("name", "default") ); List hotkeys = ImmutableList.of( new ConfigHotkey("action1", "G"), new ConfigHotkey("action2", "H") ); // Write configs to JSON JsonObject root = new JsonObject(); ConfigUtils.writeConfigBase(root, "General", generalOptions); ConfigUtils.writeHotkeys(root, "Hotkeys", hotkeys); // Save JSON to file Path configPath = FileUtils.getConfigDirectory().resolve("mymod.json"); JsonUtils.writeJsonToFile(root, configPath); // Read configs from JSON JsonElement element = JsonUtils.parseJsonFile(configPath); if (element != null && element.isJsonObject()) { JsonObject loadedRoot = element.getAsJsonObject(); ConfigUtils.readConfigBase(loadedRoot, "General", generalOptions); ConfigUtils.readHotkeys(loadedRoot, "Hotkeys", hotkeys); } // For configs with both boolean and hotkey (like IHotkeyTogglable) List toggleOptions = ImmutableList.of( new ConfigBooleanHotkeyed("feature1", false, "F1"), new ConfigBooleanHotkeyed("feature2", true, "F2") ); ConfigUtils.writeHotkeyToggleOptions(root, "FeatureHotkeys", "FeatureToggles", toggleOptions); ConfigUtils.readHotkeyToggleOptions(root, "FeatureHotkeys", "FeatureToggles", toggleOptions); ``` -------------------------------- ### Create Multi-Key Hotkey Source: https://context7.com/sakura-ryoko/malilib/llms.txt Sets up a hotkey requiring a combination of keys (e.g., Ctrl+Shift+S). Useful for actions that need to avoid accidental activation. ```java import fi.dy.masa.malilib.config.options.ConfigHotkey; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.hotkeys.IHotkeyCallback; import fi.dy.masa.malilib.hotkeys.KeyAction; // Multi-key combination (Ctrl+Shift+S) ConfigHotkey saveConfig = new ConfigHotkey("saveConfig", "LEFT_CONTROL,LEFT_SHIFT,S", "Save current configuration"); ``` -------------------------------- ### Create Color Configuration Source: https://context7.com/sakura-ryoko/malilib/llms.txt Initializes a color configuration option using ARGB hex format. Use for customizable colors in rendering or UI elements. ```java import fi.dy.masa.malilib.config.options.ConfigColor; import fi.dy.masa.malilib.util.data.Color4f; // Create color config (hex format: 0xAARRGGBB) ConfigColor highlightColor = new ConfigColor("highlightColor", "0xFF00FF00", "Selection highlight color"); ``` -------------------------------- ### KeybindSettings Configuration Source: https://context7.com/sakura-ryoko/malilib/llms.txt Configures the behavior of keybinds including activation context, trigger actions, and exclusivity settings. ```APIDOC ## KeybindSettings Configuration ### Description Configures when and how keybinds activate, including context (in-game vs GUI), activation trigger, and key ordering. ### Parameters #### Request Body - **context** (Context) - Required - The activation context (INGAME, GUI, or ANY). - **action** (KeyAction) - Required - The trigger action (PRESS, RELEASE, or BOTH). - **allowExtraKeys** (boolean) - Required - Whether other keys can be held simultaneously. - **orderSensitive** (boolean) - Required - Whether key order matters. - **exclusive** (boolean) - Required - Whether this keybind prevents others from triggering. - **cancel** (boolean) - Required - Whether to cancel vanilla key processing. - **allowEmpty** (boolean) - Required - Whether to allow an empty keybind. ### Request Example { "context": "ANY", "action": "BOTH", "allowExtraKeys": true, "orderSensitive": false, "exclusive": true, "cancel": true, "allowEmpty": false } ``` -------------------------------- ### Create Simple Hotkey Source: https://context7.com/sakura-ryoko/malilib/llms.txt Defines a basic hotkey with a single keybind. Used for simple actions triggered by one key press. ```java import fi.dy.masa.malilib.config.options.ConfigHotkey; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.hotkeys.IHotkeyCallback; import fi.dy.masa.malilib.hotkeys.KeyAction; // Simple hotkey with single key ConfigHotkey openMenu = new ConfigHotkey("openMenu", "M"); ``` -------------------------------- ### Implement Hotkey Action Callback with IHotkeyCallback Source: https://context7.com/sakura-ryoko/malilib/llms.txt Define the action to execute when a hotkey is triggered. The callback receives the key action and keybind, and can cancel further processing. ```java import fi.dy.masa.malilib.hotkeys.IHotkeyCallback; import fi.dy.masa.malilib.hotkeys.KeyAction; import fi.dy.masa.malilib.hotkeys.IKeybind; // Implement callback for hotkey action IHotkeyCallback myCallback = new IHotkeyCallback() { @Override public boolean onKeyAction(KeyAction action, IKeybind key) { if (action == KeyAction.PRESS) { // Handle key press System.out.println("Key pressed: " + key.getKeysDisplayString()); performAction(); return true; // Cancel further processing } else if (action == KeyAction.RELEASE) { // Handle key release System.out.println("Key released"); } return false; // Allow further processing } private void performAction() { // Your action here } }; // Assign callback to keybind configHotkey.getKeybind().setCallback(myCallback); ``` -------------------------------- ### Display In-Game Messages with InfoUtils Source: https://context7.com/sakura-ryoko/malilib/llms.txt Use InfoUtils to display messages in the action bar, as floating in-game messages, or within the GUI if open. Messages can have custom lifetimes and types like INFO, WARNING, ERROR, SUCCESS. ```java import fi.dy.masa.malilib.util.InfoUtils; import fi.dy.masa.malilib.gui.Message.MessageType; // Show message in action bar (above hotbar) InfoUtils.printActionbarMessage("Hello, %s!", playerName); ``` ```java // Show in-game floating message InfoUtils.showInGameMessage(MessageType.INFO, "Operation completed"); InfoUtils.showInGameMessage(MessageType.WARNING, "Low resources!"); InfoUtils.showInGameMessage(MessageType.ERROR, "Failed to save!"); ``` ```java // Show with custom lifetime (in milliseconds) InfoUtils.showInGameMessage(MessageType.SUCCESS, 10000, "Saved successfully!"); ``` ```java // Show in GUI if open, otherwise show in-game InfoUtils.showGuiOrInGameMessage(MessageType.INFO, "Config updated"); ``` ```java // Show in GUI if open, otherwise show in action bar InfoUtils.showGuiOrActionBarMessage(MessageType.INFO, "Quick status update"); ``` ```java // Show boolean toggle message (common for feature toggles) InfoUtils.printBooleanConfigToggleMessage("Fly Mode", true); // "Fly Mode: ON" InfoUtils.printBooleanConfigToggleMessage("Fly Mode", false); // "Fly Mode: OFF" ``` -------------------------------- ### IHotkeyCallback Implementation Source: https://context7.com/sakura-ryoko/malilib/llms.txt Defines the interface for handling hotkey trigger events. ```APIDOC ## IHotkeyCallback ### Description Defines the action to execute when a hotkey is triggered. ### Parameters #### Request Body - **action** (KeyAction) - Required - The action type (PRESS or RELEASE). - **key** (IKeybind) - Required - The keybind instance triggered. ### Response #### Success Response (200) - **result** (boolean) - Returns true to cancel further processing, false otherwise. ``` -------------------------------- ### Register Mod Initialization Handler Source: https://context7.com/sakura-ryoko/malilib/llms.txt Use InitializationHandler to register mod handlers for configs and keybinds after Minecraft is ready. Ensure your mod's onInitialize method calls this registration. ```java import fi.dy.masa.malilib.event.InitializationHandler; import fi.dy.masa.malilib.interfaces.IInitializationHandler; import fi.dy.masa.malilib.config.ConfigManager; import fi.dy.masa.malilib.event.InputEventHandler; // In your mod's onInitialize method public class MyMod implements ModInitializer { @Override public void onInitialize() { // Register initialization handler InitializationHandler.getInstance().registerInitializationHandler( new IInitializationHandler() { @Override public void registerModHandlers() { // Register config handler ConfigManager.getInstance().registerConfigHandler( "mymodid", new MyModConfigHandler() ); // Register keybind provider InputEventHandler.getKeybindManager().registerKeybindProvider( new MyModKeybindProvider() ); } @Override public void preGameInit(Path runDir) { // Optional: Very early initialization // Called before Minecraft systems initialize } } ); } } ``` -------------------------------- ### Create Boolean Hotkey with Custom Settings Source: https://context7.com/sakura-ryoko/malilib/llms.txt Configures a boolean toggle with custom keybind settings, allowing it to activate in different contexts like GUIs. Use for flexible toggle controls. ```java // With custom keybind settings (activates in GUI context too) ConfigBooleanHotkeyed showHud = new ConfigBooleanHotkeyed("showHud", true, "H", KeybindSettings.create( KeybindSettings.Context.ANY, // Works in-game and in GUIs KeyAction.PRESS, // Trigger on key press false, // Don't allow extra keys true, // Order sensitive false, // Not exclusive true // Cancel further processing ), "Toggle HUD visibility"); ``` -------------------------------- ### Register Mod Configuration with ConfigManager Source: https://context7.com/sakura-ryoko/malilib/llms.txt Use ConfigManager to register and manage your mod's configuration lifecycle, coordinating loading and saving across all registered mods. ```java import fi.dy.masa.malilib.config.ConfigManager; import fi.dy.masa.malilib.config.IConfigHandler; import fi.dy.masa.malilib.config.IConfigManager; // Get the config manager instance IConfigManager configManager = ConfigManager.getInstance(); // Register your mod's config handler configManager.registerConfigHandler("mymodid", new IConfigHandler() { @Override public void load() { // Load configs from file MyModConfigs.loadFromFile(); } @Override public void save() { // Save configs to file MyModConfigs.saveToFile(); } @Override public void onConfigsChanged() { // Called when configs changed via GUI save(); load(); // Apply any runtime changes applyConfigChanges(); } }); // Notify that configs changed (triggers save/load cycle) configManager.onConfigsChanged("mymodid"); ``` -------------------------------- ### ConfigManager Registration Source: https://context7.com/sakura-ryoko/malilib/llms.txt Handles registration and lifecycle of mod configurations. ```APIDOC ## ConfigManager Registration ### Description Registers a configuration handler for a specific mod ID to manage loading and saving cycles. ### Parameters #### Request Body - **modId** (String) - Required - The unique identifier for the mod. - **handler** (IConfigHandler) - Required - The implementation of load, save, and onConfigsChanged methods. ``` -------------------------------- ### Create Boolean Hotkey Toggle Source: https://context7.com/sakura-ryoko/malilib/llms.txt Combines a boolean configuration option with a hotkey that toggles its value. Automatically displays status messages to the user. ```java import fi.dy.masa.malilib.config.options.ConfigBooleanHotkeyed; import fi.dy.masa.malilib.hotkeys.KeybindSettings; // Boolean with hotkey toggle ConfigBooleanHotkeyed flyMode = new ConfigBooleanHotkeyed("flyMode", false, "F", "Enable fly mode"); ``` -------------------------------- ### Set Color Value from String Source: https://context7.com/sakura-ryoko/malilib/llms.txt Updates the color configuration by parsing a new ARGB hex string. Allows dynamic color changes based on user input or game events. ```java // Set from string highlightColor.setValueFromString("0x80FF0000"); // Semi-transparent red ``` -------------------------------- ### Check for Keybind Conflicts Source: https://context7.com/sakura-ryoko/malilib/llms.txt Compares two keybinds to detect potential conflicts where they might be activated simultaneously. Helps prevent unintended behavior. ```java // Check for conflicts with another keybind IKeybind otherKeybind = KeybindMulti.fromStorageString("LEFT_ALT,X", KeybindSettings.DEFAULT); if (keybind.overlaps(otherKeybind)) { System.out.println("Warning: Keybinds may conflict!"); } ``` -------------------------------- ### Manage Input Events with InputEventHandler Source: https://context7.com/sakura-ryoko/malilib/llms.txt Register keybind providers and custom input handlers to process keyboard and mouse events. Call updateUsedKeys after modifying keybind mappings to ensure changes take effect. ```java import fi.dy.masa.malilib.event.InputEventHandler; import fi.dy.masa.malilib.hotkeys.IKeybindManager; import fi.dy.masa.malilib.hotkeys.IInputManager; import fi.dy.masa.malilib.hotkeys.IKeybindProvider; import fi.dy.masa.malilib.hotkeys.IKeyboardInputHandler; import fi.dy.masa.malilib.hotkeys.IMouseInputHandler; // Get managers IKeybindManager keybindManager = InputEventHandler.getKeybindManager(); IInputManager inputManager = InputEventHandler.getInputManager(); // Register keybind provider (called during mod init) keybindManager.registerKeybindProvider(new IKeybindProvider() { @Override public void addKeysToMap(IKeybindManager manager) { // Add all keybinds to the active map for (IHotkey hotkey : MyModHotkeys.ALL_HOTKEYS) { manager.addKeybindToMap(hotkey.getKeybind()); } } @Override public void addHotkeys(IKeybindManager manager) { // Register hotkeys for the combined hotkey list GUI manager.addHotkeysForCategory("MyMod", "General", MyModHotkeys.GENERAL_HOTKEYS); manager.addHotkeysForCategory("MyMod", "Rendering", MyModHotkeys.RENDER_HOTKEYS); } }); // Register custom keyboard handler inputManager.registerKeyboardInputHandler(new IKeyboardInputHandler() { @Override public boolean onKeyInput(KeyEvent event, boolean eventKeyState) { if (eventKeyState && event.key() == KeyCodes.KEY_TAB) { // Handle Tab key press return true; // Cancel further processing } return false; } }); // Register custom mouse handler inputManager.registerMouseInputHandler(new IMouseInputHandler() { @Override public boolean onMouseClick(MouseButtonEvent event, boolean eventButtonState) { if (eventButtonState && event.input() == 0) { // Left click // Handle left click return false; } return false; } @Override public boolean onMouseScroll(double mouseX, double mouseY, double amount) { if (isFeatureActive()) { // Handle scroll return true; } return false; } @Override public void onMouseMove(double mouseX, double mouseY) { // Track mouse position } }); // Update keybinds after changes keybindManager.updateUsedKeys(); ``` -------------------------------- ### Set Hotkey Callback Source: https://context7.com/sakura-ryoko/malilib/llms.txt Assigns a callback function to a hotkey to execute custom logic when the keybind is activated. The callback receives the key action and key code. ```java // Get the keybind and set callback openMenu.getKeybind().setCallback((action, key) -> { if (action == KeyAction.PRESS) { // Open menu when key is pressed System.out.println("Opening menu..."); return true; // Return true to cancel further key processing } return false; }); ``` -------------------------------- ### Modify Keybind Keys Programmatically Source: https://context7.com/sakura-ryoko/malilib/llms.txt Allows dynamic modification of the keys that constitute a keybind. Use to change key combinations at runtime. ```java // Modify keys programmatically keybind.clearKeys(); keybind.addKey(KeyCodes.KEY_LEFT_ALT); keybind.addKey(KeyCodes.KEY_Z); ``` -------------------------------- ### Check if Keybind Was Pressed Source: https://context7.com/sakura-ryoko/malilib/llms.txt Tests if a specific keybind was activated (pressed) during the current game tick. Ideal for triggering one-time actions. ```java // Check if keybind was just pressed this tick if (keybind.isPressed()) { System.out.println("Keybind activated!"); } ``` -------------------------------- ### Toggle Boolean Value Programmatically Source: https://context7.com/sakura-ryoko/malilib/llms.txt Changes the boolean state of a ConfigBooleanHotkeyed option directly in code. Useful for setting default states or reacting to other game events. ```java // Toggle programmatically flyMode.toggleBooleanValue(); ``` -------------------------------- ### Check if Hotkey is Held Source: https://context7.com/sakura-ryoko/malilib/llms.txt Determines if a hotkey is currently being held down. Useful for continuous actions while a key is pressed. ```java // Check if keybind is currently held if (openMenu.getKeybind().isKeybindHeld()) { // Handle held state } ``` -------------------------------- ### Check if Keybind is Held Source: https://context7.com/sakura-ryoko/malilib/llms.txt Determines if the keys associated with a keybind are currently being held down. Useful for actions that require continuous input. ```java // Check if currently held down if (keybind.isKeybindHeld()) { System.out.println("Keybind is being held"); } ``` -------------------------------- ### Check if Specific Key is Down Source: https://context7.com/sakura-ryoko/malilib/llms.txt Determines if a particular key on the keyboard is currently being held down. Useful for checking modifier keys or specific input states. ```java // Check if specific key is down if (KeybindMulti.isKeyDown(KeyCodes.KEY_LEFT_SHIFT)) { // Shift is held } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.