Module

abstract class Module(name: String, keyCode: Int = Keyboard.KEY_NONE, category: Category = Category.MISC, toggled: Boolean = false, settings: ArrayList<Setting<*>> = ArrayList(), description: String = "")

Super class for all Modules in the mod.

Annotate with AlwaysActive to have a Module always registered to the Event Bus regardless of the Module being enabled.

Making your own Module

To make your own Module simply create an object which inherits from this class and add it to the list of modules in ModuleManager. The sample provided below shows how you can do this.

Adding settings to your Module.

If you want your Module to have Settings which appear in the GUI you need to define the settings in your Module and also register them by adding them to the settings list.

There are four different ways to achieve this. These are shown in the following on the example of a NumberSetting. Probably the easiest to understand is to first define a property in your Module which is an Instance of the setting you want. And then registering that setting in the initializer.

private val distance : NumberSetting = NumberSetting("Distance", 4.0)

init{
    this.addSettings(distance)
}

This syntax can be shortened by using the register method directly when defining your setting. Inside of Module classes the unary Add operator is overridden for members of Setting to register them. So the following two lines will do exactly the same.

private val distance : NumberSetting = register(NumberSetting("Distance", 4.0))
private val distance : NumberSetting = +NumberSetting("Distance", 4.0)

Lastly the probably most convenient way of adding settings is through the use of delegation. The key difference here is that the property you are defining is not referring to the Setting but rather directly to its value. Since often the value is the only relevant aspect of the setting within the Modules code this approach is a lot more convenient to use in most cases. Notice how the type of distance is Double in the following example and not NumberSetting.

private val distance : Double by NumberSetting("Distance", 4.0)

Adding more functionality to your Settings.

The setting classes offer support for more functionality, namely adding a dependency for the setting to show in the GUI and the option to perform custom processing of changes to the setting. The sample from AutoClicker below shows both of these being used. The input transform is used to further limit the range in which the slider can be moved. And the dependency is set so that the setting only shows in the click gui when the corresponding click mode is enabled.

Adding a HUD to your Module

To add a HUD to your module simply declare an object which inherits from the HudElement class within your Module. For this HUD element to be active you need to register it. All you need to do for that is to annotate it with the RegisterHudElement annotation. Inside your HUD element object you need to implement the renderHud method. This ís responsible for rendering the element.

The following example shows how to use it.

object MyModule : Module("My Module", category = Category.RENDER) {
    @RegisterHudElement
    object MyHudElement : HudElement(this, 0, 150, 100, 20) {
        override fun renderHud() {
            // Rendering implementation
        }
    }
}

Author

Aton

Samples

import floppaclient.FloppaClient.Companion.mc
import floppaclient.events.ClickEvent
import floppaclient.module.Category
import floppaclient.module.Module
import floppaclient.module.settings.Setting.Companion.withDependency
import floppaclient.module.settings.Setting.Companion.withInputTransform
import floppaclient.module.settings.impl.BooleanSetting
import floppaclient.module.settings.impl.NumberSetting
import floppaclient.utils.Utils
import floppaclient.utils.inventory.InventoryUtils.isHolding
import floppaclient.utils.inventory.SkyblockItem
import net.minecraft.util.MathHelper
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.random.Random
fun main() { 
   //sampleStart 
   private val maxCps: NumberSetting = NumberSetting("Max CPS", 12.0, 1.0, 20.0, 1.0, description = "Maximum cps for left click.")
        .withInputTransform { input, setting ->
            MathHelper.clamp_double(input, minCps.value, setting.max)
        }.withDependency { leftClick.enabled } 
   //sampleEnd
}
import floppaclient.FloppaClient.Companion.mc
import floppaclient.events.PositionUpdateEvent
import floppaclient.module.Category
import floppaclient.module.Module
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
fun main() { 
   //sampleStart 
   /**
 * Module that makes you always sprint.
 * @author Aton
 */
object AutoSprint : Module(
    "Auto Sprint",
    category = Category.MISC,
    description = "A simple auto sprint module that toggles sprinting when moving forwards and not collided " +
            "with anything."
) {
    @SubscribeEvent
    fun onPositionUpdate(event: PositionUpdateEvent.Pre) {
        if (!mc.thePlayer.isCollidedHorizontally && mc.thePlayer.moveForward > 0) {
            mc.thePlayer.isSprinting = true
        }
    }
} 
   //sampleEnd
}

See also

Parameters

name

The name of the Module. This has to be unique! This name is shown in the GUI and used to identify the module in the config.

keyCode

Key code for the Modules key-bind.

category

Determines in which category Panel the module will appear in the GUI.

description

A description of the module and its usage that is shown in the Advanced GUI.

Constructors

Link copied to clipboard
fun Module(name: String, category: Category = Category.MISC, description: String = "")

A simplified constructor to inherit from.

Link copied to clipboard
fun Module(name: String, keyCode: Int = Keyboard.KEY_NONE, category: Category = Category.MISC, toggled: Boolean = false, settings: ArrayList<Setting<*>> = ArrayList(), description: String = "")

Functions

Link copied to clipboard
fun addSettings(vararg setArray: Setting<*>)

Adds all settings in the input to the settings field of the module. This is required for saving and loading these settings to / from a file. Keep in mind, that these settings are passed by reference, which will get lost if the original setting is reassigned.

Link copied to clipboard
Link copied to clipboard

Triggers the module initialization.

Link copied to clipboard

Loads self registering elements of the module such as hud elements.

Link copied to clipboard
open fun onDisable()

This method is run whenever the module is disabled.

Link copied to clipboard
open fun onEnable()

This method is run whenever the module is enabled.

Link copied to clipboard
open fun onInitialize()

This method will be run on the FMLLoadCompleteEvent on game startup after the config is loaded.

Link copied to clipboard
open fun onKeyBind()

This method is run whenever the key-bind for the Module is pressed.

Link copied to clipboard
fun <K : Setting<*>> register(setting: K): K

Registers the setting to this Module. This will make the setting appear in the GUI and save to the config. The following is an example of how it can be used to define a setting for a module.

Link copied to clipboard
fun toggle()

Will toggle the module.

Link copied to clipboard
operator fun <K : Setting<*>> K.unaryPlus(): K

Overloads the unaryPlus operator for Setting classes to register them to the module. The following is an example of how it can be used to define a setting for a module.

Properties

Link copied to clipboard
Link copied to clipboard

A description of the module and its usage that is shown in the Advanced GUI.

Link copied to clipboard

Do NOT set this value directly, use toggle() instead!

Link copied to clipboard
Link copied to clipboard

Key code of the corresponding key bind. Mouse binds will be negative: -100 + mouse button. This is the same way as minecraft treats mouse binds.

Link copied to clipboard
Link copied to clipboard

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard