Die technische Dokumentation ist in englischer Sprache verfügbar. Code- und Feldnamen folgen der aktuellen Mod-API.
MODDING-DOKUMENTATION
Java extensions
Use Java when your mod needs a supported callback or policy. Content definitions still belong in JSON. Follow Setup to build the sample project.
1. Register your extension
Implement GameMod and name that class in code.entrypoint in mod.json.
The game calls register(ModContext) once during startup. Register your hooks there.
public final class MyMod implements GameMod {
public MyMod() {}
@Override
public void register(ModContext context) {
context.registerColonyExtension(MyColonyRules::new);
}
}
This is a structural excerpt. MyColonyRules must implement ColonyExtension; the
complete starter shows a compilable
entry point with imports and documented hooks. Each world needs a fresh extension instance.
2. Choose the service
| Behaviour | Guide |
|---|---|
| Read final definitions | ModContext.onRegistriesReady in the Java reference |
| Change colony rules and save mod state | Colony simulation |
| React to committed changes | Events |
| Request work or transfer stock | Inventory and construction |
| Configure trade or map locations | Trading and campaign cities |
| Add settings and keyboard commands | Settings |
| Show native controls | Panels and inspectors |
The generated Java reference contains the complete registration surface, including equipment transforms, particle shapes and shared trade configuration.
3. Read snapshots and issue validated commands
Use the context supplied to the current callback. For example, inside a colony callback:
var person = context.view().citizen(citizenId);
if (person != null && person.living()) {
var home = context.view().homeOf(person.id());
// Decide what your mod should do using these read-only values.
}
citizenId is a stable ID received from an event or stored by your mod. A list index is not an
actor ID. Query again after commands to observe current state.
- Contexts and their services expire when the callback returns; use them only on that thread.
- Detached records are safe to retain, but do not update themselves.
- Check command return values. Read the documented bounds and rejection conditions.
- Keep callbacks short and deterministic. Use the supplied random facilities.
- Store durable outcomes in your mod's
savemap and restore them without repeating completed actions.
4. Validate and test
Apply & reload checks compiled API references, registrations and registry callbacks. It also exercises disposable extension restore/save round trips. Keep constructors and persistence callbacks free of external side effects. Test the actual behaviour and save/load in a test world.
The SDK exposes supported contracts, not mutable engine managers. Compiled internal-engine references and bundled engine/API classes are rejected. Java code still runs with the game's process permissions; validation is not a security sandbox. See supported boundaries.
