For mod developers
What other mods can do with Charted, the rules every call follows, and how to call it without making it a requirement.
Charted has four public APIs, all in the package com.charted.api and all on the client. A modpack can also ship waypoints without any code.
| API | What it is for | Since |
|---|---|---|
| ChartedWaypoints | The world's waypoints: read, add and remove your own, hear about changes. | 0.1.0 |
| ChartedMarkers | Points and areas of your own on the minimap and world map: claims, towns, quest targets. | 0.1.0 |
| ChartedMap | Open the world map on a spot, add to its right-click menu, hide the minimap for a while, what the map knows about a column. | 0.1.0 |
| ChartedActions | Charted's quick actions, for shortcut wheels. | 0.1.0 |
| waypoints.json | Waypoints a modpack ships, added once to each world they are for. | 0.1.0 |
Only the com.charted.api package is stable. Everything else can change in any release, and a mixin into Charted's other classes will break.
The rules every call follows #
- Every call is a static method taking and returning plain JDK types, so a mod can call it by reflection without compiling against Charted.
- Client side, client thread only (marks may be set from any thread). Call
isAvailable()first; when it is false every call does nothing and returns empty, null or false. Nothing throws. - Whatever a mod adds goes under an owner, its own mod id.
ChartedMap.release(owner)takes all of it away again. Code you hand in that throws is logged once and left out. - The player stays in charge: waypoints a mod adds are theirs to edit and delete, listed under the mod's name.
Keep Charted optional #
Charted is client-side, and most players of your mod will not have it. Two ways to call it without making it a requirement:
- Check
FabricLoader.getInstance().isModLoaded("charted"), or on NeoForgeModList.get().isLoaded("charted"), and keep the calls in a class of their own, so Charted's classes only load when it is there. - Or call it by reflection. Every call takes only JDK types, so there is nothing to compile against. See the example.
public final class MyModClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
if (FabricLoader.getInstance().isModLoaded("charted")) {
ChartedCompat.init();
}
}
}
// A class of its own: Charted's classes only load when Charted is there.
final class ChartedCompat {
static void init() {
ChartedMarkers.point("mymod", "spawn", "minecraft:overworld", 0, 0, 0x3080FF, "Spawn");
}
}Charted runs on Fabric on 1.21.1 to 26.3, and on NeoForge on 26.1.2 to 26.3. It is client-side only, so call it from client code.
Questions #
Something the API should do, or something that does not work: ask on Discord.
Something missing or wrong on this page? Say so on Discord.