Skip to main content

Overview

The ClientModule class is the base class for all modules in LiquidBounce. A module (also called a “hack”) can be enabled/disabled and handles game events when active.

Class Signature

open class ClientModule(
    name: String,
    category: ModuleCategory,
    bind: Int = InputConstants.UNKNOWN.value,
    bindAction: InputBind.BindAction = InputBind.BindAction.TOGGLE,
    state: Boolean = false,
    notActivatable: Boolean = false,
    disableActivation: Boolean = notActivatable,
    disableOnQuit: Boolean = false,
    aliases: List<String> = emptyList(),
    hide: Boolean = false
) : ToggleableValueGroup, EventListener, MinecraftShortcuts
name
String
required
The module’s display name
category
ModuleCategory
required
The category this module belongs to (Combat, Movement, Render, etc.)
bind
Int
default:"InputConstants.UNKNOWN.value"
The default keybind for toggling the module
bindAction
InputBind.BindAction
default:"TOGGLE"
The bind action type: TOGGLE, HOLD, or SMART
state
Boolean
default:"false"
Whether the module is enabled by default
notActivatable
Boolean
default:"false"
Disables settings that are not needed if the module can’t be enabled
disableActivation
Boolean
default:"notActivatable"
Prevents the module from being activated
disableOnQuit
Boolean
default:"false"
Automatically disables the module when the player leaves the world
aliases
List<String>
default:"emptyList()"
Additional names under which the module is known
hide
Boolean
default:"false"
Whether the module should be hidden by default

Properties

running

val running: Boolean
Indicates whether the module is currently running. A module runs when it’s enabled, the player is in-game, or if it’s marked as notActivatable.

tag

open val tag: String?
The tag to be displayed on the HUD alongside the module name. Returns null by default.

settings

val settings: Map<String, Value<*>>
A map of all settings (values) in this module, accessible by name. Useful for scripting.

hidden

var hidden: Boolean
Controls whether the module is hidden from the HUD ArrayList.

bind

val bind: InputBind
The current keybind configuration for this module.

Methods

onRegistration

open fun onRegistration()
Called when the module is registered in the ModuleManager. Override this to perform initialization tasks.

enabledEffect

open suspend fun enabledEffect()
Launches an async task on the event listener scope when the module is turned on. Use this for coroutine-based effects that should run while the module is enabled.

tagBy

fun tagBy(setting: Value<*>)
Sets a specific setting as the source for the module’s HUD tag. The tag will automatically refresh when the setting changes.
setting
Value<*>
required
The setting whose value should be displayed as the module’s tag

message

fun message(key: String, vararg args: Any): String
Retrieves a translated message for this module from the language files.
key
String
required
The message key (will be prefixed with the module’s base key)
args
Array<Any>
Optional arguments for string formatting

Example

Here’s a complete example of creating a custom module:
object ModuleCustomFly : ClientModule(
    name = "CustomFly",
    category = ModuleCategories.MOVEMENT,
    bind = GLFW.GLFW_KEY_F,
    state = false,
    disableOnQuit = true
) {
    private val speed by float("Speed", 1.0f, 0.1f..5.0f)
    private val mode by enumChoice("Mode", FlyMode.VANILLA)
    
    enum class FlyMode(override val choiceName: String) : NamedChoice {
        VANILLA("Vanilla"),
        CREATIVE("Creative")
    }
    
    init {
        // Set the speed setting as the HUD tag
        tagBy(speed)
    }
    
    override fun onRegistration() {
        logger.info("CustomFly module registered!")
    }
    
    override suspend fun enabledEffect() {
        // This runs asynchronously when the module is enabled
        logger.info("CustomFly enabled with speed: $speed")
    }
    
    val moveHandler = handler<PlayerMoveEvent> { event ->
        when (mode) {
            FlyMode.VANILLA -> {
                player.abilities.flying = true
                player.abilities.flySpeed = speed / 10f
            }
            FlyMode.CREATIVE -> {
                event.movement.y = if (mc.options.keyJump.isPressed) speed.toDouble() else 0.0
            }
        }
    }
}

Lifecycle

  1. Registration: onRegistration() is called when added to ModuleManager
  2. Enabling: When enabled, enabledEffect() runs and event handlers start listening
  3. Running: The module processes events while running == true
  4. Disabling: Event handlers stop listening
  5. World Change: If disableOnQuit == true, module is disabled on disconnect

See Also

Build docs developers (and LLMs) love