If you use download button on GitHub, repository will not work since it is using git submodules.
To download repository with submodules use below command:
git clone --recurse-submodules https://github.com/Zergatul/cheatutils.git
To build mod by yourself go to Forge or Fabric directory and run gradlew build.
Requires JDK 25.
Download repo (or just /common/resources/web directory), and add JVM argument in Minecraft launcher like this:
-Dcheatutils.web.dir=C:\full\path\to\web\directoryNow local website uses static files from this directory instead of mod resources.
This is where most of your module code will be written.
First, navigate to the modules folder located in common/java/com/zergatul/cheatutils/modules.
Select the folder that best fits your module type.
from here on, we will refer to a theoretical module named "AutoPearl", however you should follow the same naming conventions
Create a new file : AutoPearl.java.
the class should be in this format:
package com.zergatul.cheatutils.modules.automation;
import com.zergatul.cheatutils.modules.Module;
public class AutoPearl implements Module {
public static final AutoPearl instance = new AutoPearl();
private AutoPearl() {
}
}Make sure to add the line:
package com.zergatul.cheatutils.modules.<folder>;
<folder> should be where your class file lives inside the modules folder.
in this example, we are putting this under automation:
package com.zergatul.cheatutils.modules.automation;
For the purposes of this explanation, it is assumed your module is named as "AutoPearl"
Navigate to Modules.java
Add your module to the following function
public static void register() {
register(AutoPearl.instance);
}Make sure you place it in the right position, modules are initialized in the order listed here. This includes the order of their events added to EventsApi
Note
This only applies to legacy modules that do not specify their own importance. Default importance for attached events is 0
Navigate to common/java/com/zergatul/cheatutils/configs
create a new file AutoPearlConfig.java
package com.zergatul.cheatutils.configs;
public class AutoPearlConfig extends ModuleConfig implements Sanitizable {
private AutoPearlConfig() {
}
@Override
public void sanitize() {
return;
}
}add your config validation inside the sanitize() method, this is where you will add limits to your fields, for example clamping the range of a value.
If your API will be accessible from the scripting, it is highly recommended to include validation for any fields.
Note
In case if your module does not require validation, you can skip implements Sanitizable and the overridden public void Sanitize() function. When doing this, also skip adding validation to Root.java
If your module does not require enable / disable, you can skip extends ModuleConfig as well. This also means you cannot use the enabled boolean or the isEnabled() inherited functions. Keep this in mind when creating the website / code for it.
you can also add any more functions or values to change here. for example:
package com.zergatul.cheatutils.configs;
public class AutoPearlConfig extends ModuleConfig implements Sanitizable {
public boolean bl1;
public double db1;
public AutoPearlConfig() {
bl1 = true;
db1 = 100;
}
@Override
public void sanitize() {
return;
}
}And so on. These must be public, you can also use methods internally, however methods will not work with the website API. That API directly modifies fields.
Any assignments in the class constructor are only used if your saved configuration in the mod has no matching values This means that these assignments act as the default configuration of your module before the user makes any changes.
an example of a minimal config which does not need validation or enable variable:
public class AutoPearlConfig {}How to access config
Use this pattern to access the config variables:
import com.zergatul.cheatutils.configs.AutoPearlConfig;
import com.zergatul.cheatutils.configs.ConfigStore;
AutoPearlConfig config = ConfigStore.instance.getConfig().autoPearlConfig;
// Access variables with usual class pattern
if(!config.enabled)return;
Next, navigate to Config.java, located in the same directory.
Add your config to the class
public AutoPearlConfig autoPearlConfig = new AutoPearlConfig();
IF your module uses sanitize() method, make sure to add these lines under public void sanitize()
autoPearlConfig.sanitize();
Navigate to common/java/com/zergatul/cheatutils/scripting/modules/
make a new file AutoPearlApi.java
add these lines
package com.zergatul.cheatutils.scripting.modules;
import com.zergatul.cheatutils.configs.AutoPearlConfig;
import com.zergatul.cheatutils.configs.ConfigStore;
public class AutoPearlApi extends ModuleApi<AutoPearlConfig> {
@Override
protected AutoPearlConfig getConfig() {
return ConfigStore.instance.getConfig().autoPearlConfig;
}
}(refers to user side scripting)
This step is OPTIONAL and not required for module to function. If you want your module configuration to be accessed from scripting However, it is recommended to do this step
Navigate to common/java/com/zergatul/cheatutils/scripting/Root.java
Add the following lines inside the Root class.
public static AutoPearlApi autoPearl = new AutoPearlApi();Adding your module to the website
Navigate to common/resources/web/modules.js
Add your module under line 21 with the following format:
module({
group: 'groupName',
name: 'Display Name',
component: 'componentName',
path: 'class-name',
tags: ['search', 'terms', 'identifers']
});The search terms (tags) used should be reflective of the function of the module. Make sure you add your module to the correct section with the rest of its group These are the following groups that can be used:
'automation'
'esp'
'hacks'
'visuals'
'scripting'
'utility'
In our example, we use 'automation', change this to match your module type:
Example:
module({
group: 'automation',
name: 'Auto Pearl',
component: 'AutoPearl',
path: 'auto-pearl',
tags: ['pearl', 'automation', 'throw']
});now navigate to common/resources/web/components
next, navigate to the relevant folder for your module from the available folders. This is mapped to the groups used, so ensure you use the same folder.
Create 2 new files:
- AutoPearl.js
- AutoPearl.html
inside the JavaScript file, add the following:
import { createSimpleComponent } from '/components/SimpleModule.js';
export function createComponent(template) {
return createSimpleComponent('/api/auto-pearl', template);
}if you use any new components as listed in common/resources/web/components.js in your html, make sure to include them in your javascript file
for example:
import { createSimpleComponent } from '/components/SimpleModule.js'
export function createComponent(template) {
return createSimpleComponent('/api/auto-pearl', template, {
components: ['CodeBlock', 'ColorBox']
});
}This guide will focus on the working.
For style and other formatting / component usage, look at the html of other modules already implemented
your barebones html file should look like this:
<div class="module-main" v-if="config">
</div>all components can be found at common/resources/web/components/common