Start here
Quick start
Three files take an empty Fabric mod to a module that is ticked and drawn alongside the built-in seven, with a page of its own in the settings screen. No core modification required.
Safe to build on. Every hook added since the API first shipped in 1.1.0 comes with a default, so an addon compiled against an older release keeps running on a newer one.
Step 1
Add the dependency
The API is published through JitPack. Add the repository and the dependency, then reload Gradle.
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.Eymistaken:Eymistaken-s-HUD:main-SNAPSHOT'
}repositories {
maven("https://jitpack.io")
}
dependencies {
implementation("com.github.Eymistaken:Eymistaken-s-HUD:main-SNAPSHOT")
}implementation, not modImplementation, on 26.x. Minecraft 26.x ships unobfuscated and Loom no longer remaps mods, so the mod-specific configurations are gone and modImplementation fails with "configuration not found". 1.21.x is the exception: it is still obfuscated, so there the jar goes through modImplementation, as below.
To pin a fixed build, put a release version in place of main-SNAPSHOT, without the leading v; JitPack strips it from the tag. The latest release says which one that is.
Other Minecraft versions
The line above is the 26.3 jar. From 1.2.6 on, the jars for 26.1 to 26.2 and for 1.21.9 to 1.21.11 are published beside it, each under a classifier named after its range. The @jar keeps the 26.3 jar's dependencies out of your build.
// Minecraft 26.1 to 26.2
implementation 'com.github.Eymistaken:Eymistaken-s-HUD:1.2.6:26.1-26.2@jar'
// Minecraft 1.21.9 to 1.21.11, which is obfuscated, so Loom remaps the jar
modImplementation 'com.github.Eymistaken:Eymistaken-s-HUD:1.2.6:1.21.9-1.21.11@jar'// Minecraft 26.1 to 26.2
implementation("com.github.Eymistaken:Eymistaken-s-HUD:1.2.6:26.1-26.2@jar")
// Minecraft 1.21.9 to 1.21.11, which is obfuscated, so Loom remaps the jar
modImplementation("com.github.Eymistaken:Eymistaken-s-HUD:1.2.6:1.21.9-1.21.11@jar")A 1.21.x addon builds with Java 21, and there the drawing class is called GuiGraphics: write GuiGraphics wherever the examples in this guide say GuiGraphicsExtractor. Everything else in the API is the same in all three jars.
Step 2
Write the module
Extend HudModule and implement its eight abstract methods. This is the minimum.
import com.eymistaken.simplecps.api.HudModule;
import com.eymistaken.simplecps.SimpleCPSConfig;
import net.minecraft.client.gui.GuiGraphicsExtractor;
public class MyCustomModule extends HudModule {
@Override
public String getName() {
return "myaddon:tracker"; // unique, prefixed with your mod id
}
@Override
public SimpleCPSConfig.Position getPositionType() {
return SimpleCPSConfig.Position.TOP_LEFT;
}
@Override public int getXOffset() { return 0; }
@Override public int getYOffset() { return 0; }
@Override
public boolean isEnabled() {
return true; // tie to your own config
}
@Override public int getWidth() { return 100; }
@Override public int getHeight() { return 20; }
@Override
public void extractRenderState(GuiGraphicsExtractor context, float tickDelta) {
float scale = getScale() / 100f;
context.pose().pushMatrix();
context.pose().translate((float) this.x, (float) this.y);
context.pose().scale(scale, scale);
// Draw relative to 0, 0. drawText() honors the player's
// Text Outline setting and the current fade alpha.
drawText(context, "Hello World", 0, 0, 0xFFFFFFFF);
context.pose().popMatrix();
}
}Return a real size. getWidth() and getHeight() drive stacking. Returning 0 removes the module from the layout and makes it invisible.
Names are keys. getName() keys your layout flags and saved state. registerModule() refuses a name that is taken and logs an error; check first with manager.isNameTaken(String).
Step 3
Register the plugin
Implement EymistakenHudPlugin and declare it under the eymistaken_hud entrypoint.
import com.eymistaken.simplecps.HudModuleManager;
import com.eymistaken.simplecps.api.EymistakenHudPlugin;
public class MyPluginInit implements EymistakenHudPlugin {
@Override
public void registerHudModules(HudModuleManager manager) {
manager.registerModule(new MyCustomModule());
}
}"entrypoints": {
"eymistaken_hud": [
"com.myname.myaddon.MyPluginInit"
]
}Start the game with your addon and Eymistaken's HUD installed. Your module draws at its anchor and gets its own page in the settings screen, listed under PLUGINS. Plugins are discovered after the config is read, so stored state is replayed into your module the moment it registers.
What HudModule asks of you
The eight abstract methods. Everything else on the class has a default; see the full reference.
String getName()since 1.1.0Unique key for your layout flags and saved state. Prefix it with your mod id.
SimpleCPSConfig.Position getPositionType()since 1.1.0The anchor: one of the four corners, which stack automatically, or CENTER, which is centered rather than stacked.
int getXOffset()
int getYOffset()since 1.1.0Offset from the anchor in pixels. Any non-zero offset takes the module out of auto-stacking.
boolean isEnabled()since 1.1.0Whether the module renders at all. Tie it to your own config.
int getWidth()
int getHeight()since 1.1.0The size of what you draw, with scale applied. Used by stacking, the editor and the preview card.
void extractRenderState(GuiGraphicsExtractor context, float tickDelta)since 1.1.0Draw here. Translate to this.x and this.y, then draw from the local origin.