LogoLogo
  • Introduction
  • Documentation License
  • Modding Basics
  • Getting Started
  • Configuration
    • Creating a Config
    • Config Options
      • Boolean Configs
      • Number Configs
      • Selector Configs
      • Text Configs
      • Buttons, Colors and Keybinds
      • Decorative Components
      • Custom options
    • Migration
  • Events
    • Event Basics
    • Available Events
      • ChatReceiveEvent
      • TickEvent
      • InitializationEvent
      • HudRenderEvent
      • Packet Events
      • LocrawEvent
  • Graphics & UI
    • Render Manager
      • Font Rendering
    • Elements
    • Pages
  • Commands
    • Commands
    • An Example Command
  • HUDs
    • HUD Basics
  • Utilities
    • OneConfig's Utilities
      • Notifications
      • HypixelUtils
    • OneColor
    • OneUIScreen
Powered by GitBook
On this page
  • Buttons
  • Common button
  • Keybinds
  • Colors

Was this helpful?

  1. Configuration
  2. Config Options

Buttons, Colors and Keybinds

Learn about the button, color and keybind elements that can be used in a config.

PreviousText ConfigsNextDecorative Components

Last updated 2 years ago

Was this helpful?

Buttons

Common button

The button is a simple interaction that can trigger code when pressed. It's got both single and dual-column variants.

You can create your method to run when the button is pressed using the Runnable interface:

@Button(
    name = "I'm a button",    // name beside the button
    text = "Click me!"        // text on the button itself
)
Runnable runnable = () -> {    // using a lambda to create the runnable interface.
    System.out.println("I was clicked!");
    FMLCommonHandler.instance().exitJava(69, false);
}

Keybinds

OneConfig also offers keybinds that replace Minecraft's own keybind system. Basically, it's handled and stored by OneConfig, not the game. It's got both single and dual-column variants.

This config component uses OneKeyBind to store the keybinds.

@KeyBind(
    name = "I'm a keybind!"
)
// using OneKeyBind to set the default key combo to Shift+S
public static OneKeyBind keyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S);

To register an action when a keybind is activated, add the following to your constructor:

public Config() {
    registerKeyBind(keyBind, () -> System.out.println("Look mom, a keybind!"));
}

Colors

The color option lets the user change any default color to their own, using a built-in color picker.

This config component uses OneColor to store the colors.

@Color(
    name = "Background Color"
)
OneColor testColor = new OneColor(26, 35, 143);        // default color
Buttons with single and dual variant examples
Keybind field examples, including recording state
Color examples, single and dual column
Color selector GUI examples