Module system
Warning
This page is for the LabyMod 3 Addon API, which is no longer maintained nor supported. Visit https://wiki.labymod.net/pages/addon/ for the LabyMod 4 Addon API Wiki.
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
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
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;
}
}