Skip to content

Custom Modules

SenkJu edited this page Jul 11, 2019 · 9 revisions

Example

function ExampleModule() {

    // 'getName()' returns the name of the module. This name will be used in the ClickGUI/TabGUI.
    this.getName = function() {
        return "TestModule";
    };

    /* 'getDescription()' returns the description of the module. 
    It can be seen when hovering the module in the ClickGUI. */
    this.getDescription = function() {
        return "This module has been created using LiquidBounce's scripting API.";
    };

    // 'getCategory()' returns the name of the ClickGUI/TabGUI category the module should be added to.
    this.getCategory = function() {
        return "Exploit";
    };

    // 'onEnable()' is being executed once the user activated the module.
    this.onEnable = function() {
        chat.print("§c§lHey! I am now enabled.");
    };

    /* 'onDisable()' is being executed once the user disabled the module. 
    Changed Minecraft values should be reset here. */
    this.onDisable = function() {
        chat.print("§c§lBye! I am now disabled.");
    };

    /* 'onUpdate()' is being executed constantly (every tick => 20 times per seconds) 
    if the module is enabled. */
    this.onUpdate = function() {
        mc.thePlayer.swingItem();
    }
}

Module Events

this.onEnable = function() {
    // Code in here will be executed directly after the module has been enabled by the user 
};

this.onDisable = function() {
    // Code in here will be executed directly after the module has been disabled by the user 
};

this.onUpdate = function() {
    // Code in here is being executed every tick (~20 times per seconds)
};

this.onMotion = function(event) {
    // Code in here is being executed everytime the player receives motion

    var eventState = event.eventState;
    eventState.stateName; // PRE or POST 
};

this.onRender2D = function(event) {
    // Code in here will be executed when the client draws its 2D elements

    var partialTicks = event.partialTicks; // Used to render FPS independent animations
};

this.onRender3D = function(event) {
    // Code in here will be executed when the client draws its 3D elements

    var partialTicks = event.partialTicks; // Used to render FPS independent animations
};

this.onAttack = function(event) {
    // Code in here will be executed when an entity is being attacked

    var targetEntity = event.targetEntity;
};

this.onJump = function(event) {
    // Code in here will be executed when the player jumps
    
    event.cancelEvent() // Cancels the event
    event.cancel // Whether the event has been cancelled

    var motion = event.motion;
    event.motion = 0.42;
};

this.onPacket = function(event) {
    // Code in here will be executed when the client receives a packet

    event.cancelEvent() // Cancels the event
    event.cancel // Whether the event has been cancelled

    var packet = event.packet;
};