Content registration
Add these examples to the first mod's OnInitializeMelon, after creating content. Register on the main thread before opening a world, then leave definitions unchanged.
Keys and ownership
content.Key("chip") produces example.firstmod:chip. IDs are case-sensitive, nonblank, and cannot contain : or surrounding whitespace. Keep released IDs stable.
Each assembly needs its own mod ID. Do not register the same key twice. Items, fluids, and gases share one namespace.
Categories
content.RegisterCategory(new CategoryDefinition
{
Id = "machines",
Name = "My Machines",
SortOrder = 110
});Parts can use the local category ID "machines". Cross-mod categories need a full key such as "other.mod:machines".
Items, fluids, and gases
Add using UnityEngine; for colours.
content.RegisterItem(new ItemDefinition
{
Id = "chip", Name = "Control Chip", Mass = 0.1f, MaxStackSize = 100
});
content.RegisterFluid(new FluidDefinition
{
Id = "coolant", Name = "Coolant", Mass = 1f, Color = Color.cyan
});
content.RegisterGas(new FluidDefinition
{
Id = "gas", Name = "Example Gas", Mass = 0.01f, Color = Color.magenta
});Use positive mass and stack sizes. Registration defines an item; your mod must provide a way to obtain it.
Parts and building costs
A part clones a donor by its exact asset name, such as Constant.
content.RegisterPart(new PartDefinition
{
Id = "machine",
Name = "Chip Machine",
Donor = "Constant",
Category = "machines",
BuildingCost = new[]
{
new ItemCost { Item = ItemRef.Mod(content.Key("chip")), Quantity = 2 }
}
});This uses the category and chip above. A null building cost keeps the donor's cost; an empty array makes it free. Give the part its own unlock with Research, or it inherits donor research.
Resolve content after binding
Lookups become available when a world is ready:
content.WorldBound += () =>
{
var reference = PartRef.Mod(content.Key("controller"));
if (StriderRegistry.TryGetNumericId(reference, out var id))
MelonLogger.Msg($"Controller ID: {id}");
};Use TryGetPart, TryGetItem, or TryGetResearch when you need settings. Clear cached IDs/settings in WorldUnbinding; they belong to that world.
Full signatures and defaults are in Registry and references and Content definitions.