S9SourceNine Labs / CMAPI Docs 1.0
CMAPI / Migrations

Migrate from 0.5

Update a CMAPI 0.5 mod for the 0.6 API.

View source ↗
CMAPI 1.0.0Standalone runtimeWindows x64Tested with Planet Crafter 2.008

Migrate a CMAPI 0.5.x mod to 0.6.0

CMAPI 0.6.0 keeps the 0.5.x player, event, logging, and console-command contracts. Existing mods that use only those members generally need no source changes.

For a build that intentionally requires 0.6.0, reference the new CMAPI.API.dll and update the manifest:

JSON
{
  "MinimumApiVersion": "0.6.0"
}

Do not raise the minimum just because 0.6.0 exists. Keep the oldest version the mod actually supports so players receive an accurate compatibility message.

New read-only services

IModHelper adds:

  • Items, an IItemManager with AllItems, TryGetItem, and FindItems;
  • TerraTokens, an ITerraTokenManager with IsAvailable and Count.

Both services are Unity-free. Catalog snapshots can be empty at the main menu, and Terra Tokens are unavailable until the relevant game system exists. Query them after LocalPlayerStarted when world state is required.

CSHARP
helper.Events.Player.LocalPlayerStarted += _ =>
{
    foreach (IItemDefinition item in helper.Items.FindItems("iron"))
        Monitor.Info($"{item.Id}: {item.DisplayName}");

    if (helper.TerraTokens.IsAvailable)
        Monitor.Info($"Terra Tokens: {helper.TerraTokens.Count}");
};

Why mutation is not public yet

The 0.6.0 built-in give_item and give_money commands use internal adapters with host checks, bounds validation, capacity checks, and Planet Crafter's network-aware APIs. CMAPI does not yet expose those adapters to mods. A public mutation contract needs stable asynchronous results and explicit authority semantics so a client mod cannot silently mutate someone else's world.

Mods should not use reflection to call the built-in command internals. Use the read-only services now and wait for the public mutation service if network-safe world changes are required.