Module system

A module is a block of content, which can be enabled within our "Ingame GUI Editor". Users can customize and move modules by drag&drop. Our module system allows you to create own modules for your addon.

Registering modules

Register modules by calling the method LabyModAddon#getApi()#registerModule( Module module ).

Create your own module

Just create a class and use net.labymod.ingamegui.Module or one of the different module types we provide as the superclass.

Different module types

LabyMod provides different module types that help you to easily create modules.

  • SimpleModule - the simplest module → just a text module with one key and one value

  • SimpleTextModule - a simple text module with multiple lines

  • ColoredTextModule - a module where you can decide the texts (+ colors) shown

  • ItemModule - an item module which you can put into different item slots and which has different default module settings

  • ResizeableModule - a rectangle module that can be resized by the user

Note

onMouseClick onMouseMove etc.. They'll only be called in modules if the isMovable method returns false.

Create own module categories

You're able to create own module categories so you can create an own category for the modules your addon provides. Just use ModuleCategoryRegistry#loadCategory( ModuleCategory ) to register your own category. If you want to add a module to the category, you should override the Module#getCategory() method and return an instance of your desired category.

Example module

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package net.labymod.addons.test;

import net.labymod.ingamegui.Module;
import net.labymod.settings.elements.ControlElement;
import net.labymod.utils.Material;
import net.labymod.utils.ModColor;
import net.minecraft.client.gui.Gui;

/**
 * Test module
 */
public class TestModule extends Module {

    @Override
    public void draw( int x, int y, int rightX ) {
        // Just drawing a white rectangle
        Gui.drawRect( x, y, ( int ) (x + getWidth()), ( int ) (y + getHeight()), ModColor.toRGB( 255, 255, 255, 100 ) );
    }

    /**
     * The module's display-icon that will be shown in the module GUI
     *
     * @return the icon-data for this module
     */
    @Override
    public ControlElement.IconData getIconData() {
        // You can use ResourceLocation, items etc.
        return new ControlElement.IconData( Material.PAPER );
    }

    /**
     * The module's minecraft-width
     *
     * @return the width
     */
    @Override
    public double getWidth() {
        return 100;
    }

    /**
     * The module's minecraft-height
     *
     * @return the height
     */
    @Override
    public double getHeight() {
        return 20;
    }

    /**
     * Called after the module's config-values have been loaded
     * -> You can use this method to get attributes
     */
    @Override
    public void loadSettings() {

    }

    /**
     * The module's name that will be shown in the module GUIs etc.
     *
     * @return the display name
     */
    @Override
    public String getControlName() {
        return "Module display name";
    }

    /**
     * For translation stuff
     *
     * @return the setting name
     */
    @Override
    public String getSettingName() {
        return "modulename_id";
    }

    /**
     * The module's description that will be shown when the mouse is over the module toggle element
     *
     * @return the description or an empty string if there shouldn't be a description
     */
    @Override
    public String getDescription() {
        return "Just a test module";
    }

    /**
     * The modules are getting sorted in ascending order in the module GUI
     *
     * @return the sorting id the modules are getting sorted by
     */
    @Override
    public int getSortingId() {
        return 0;
    }
}

Example SimpleModule

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package net.labymod.addons.test;

import net.labymod.ingamegui.moduletypes.SimpleModule;
import net.labymod.settings.elements.ControlElement;
import net.labymod.utils.Material;

/**
 * Simple test module
 */
public class TestSimpleModule extends SimpleModule {
    @Override
    public String getDisplayName() {
        return "Key";
    }

    @Override
    public String getDisplayValue() {
        return "Value";
    }

    /**
     * The value that will be shown if TestSimpleModule#isShown() returns <code>false</code>
     * @return the default value
     */
    @Override
    public String getDefaultValue() {
        return "?";
    }

    @Override
    public ControlElement.IconData getIconData() {
        return new ControlElement.IconData( Material.BED );
    }

    @Override
    public void loadSettings() {

    }

    @Override
    public String getSettingName() {
        return "Simple Test Module";
    }

    @Override
    public String getDescription() {
        return "";
    }

    @Override
    public int getSortingId() {
        return 0;
    }
}