Modding:Modder Guide/APIs/Content Packs

From Stardew Valley Wiki
< Modding:Modder Guide‎ | APIs
Revision as of 03:48, 28 May 2018 by Pathoschild (talk | contribs) (move content from Modding:Modder Guide/APIs (only author is Pathoschild))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Creating SMAPI mods SMAPI mascot.png


Modding:Index

Content packs

A content pack is a sub-mod containing files your mod can read. These are installed just like a regular SMAPI mod, but don't do anything on their own. These must specify your mod in their manifest.json. See Modding:Content packs for more info about content packs.

SMAPI provides a method to get content packs loaded for your mod, and each content pack has an API you can use to read its files:

foreach(IContentPack contentPack in this.Helper.GetContentPacks())
{
    // read content pack manifest
    this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version}");

    // read a JSON file
    YourDataFile data = contentPack.ReadJsonFile<YourDataFile>("content.json");

    // load an asset or image
    Texture2D image = contentPack.LoadAsset<Texture2D>("image.png");
}