pathoschild Stardew Valley Mods

repository·develop·Indexed 21 days ago

https://github.com/pathoschild/stardewmods

A collection of SMAPI-based mods for Stardew Valley, including Automate, which enables machines to automatically pull ingredients from and push processed items into adjacent chests. Also includes documentation for The Long Night and the obsolete Rotate Toolbar mod.

Tokens
57.1K
Snippets
142
Records
277
Agent score
76%

What's inside pathoschild-stardewmods

  1. Overview of Stardew Valley SMAPI Mods

    develop

    This repository contains a collection of SMAPI (Stardew Modding API) mods for Stardew Valley. These mods range from quality-of-life improvements (like Chests Anywhere and Skip Intro) to gameplay expansions (like Tractor Mod and Central Station).

    For detailed documentation, installation instructions, and release notes for a specific mod, visit the individual subdirectories within this repository or check the provided links to Nexus Mods or ModDrop.

  2. What is a Content Patcher content pack?

    develop

    A content pack is a folder containing two mandatory JSON files: manifest.json (metadata about your mod) and content.json (the instructions for Content Patcher). By convention, custom images or files used by your pack are stored in an assets/ subfolder.

    Example structure:

    📁 Mods/
       📁 [CP] YourModName/
          🗎 content.json
          🗎 manifest.json
          📁 assets/
             🗎 example.png
  3. What is an asset in Content Patcher?

    develop

    An asset is any image, data model, or map that the game loads from its Content folder. Content Patcher allows you to modify these assets.

    Key Rules for Asset Names:

    • Do not include the Content/ prefix.
    • Do not include the file extension (e.g., .xnb or .png).
    • Do not include language codes (e.g., .fr-FR).

    Example:

    • File path: Content/Maps/spring_beach.fr-FR.xnb
    • Asset name: Maps/spring_beach
  4. Tractor Mod Compatibility and Multiplayer

    develop

    Tractor Mod is compatible with Stardew Valley 1.6+ on Linux, macOS, and Windows, in both single-player and multiplayer modes.

    Multiplayer Requirements

    • Host: Must have the mod installed.
    • Farmhands: Must have the mod installed to use tractor features or see tractor/garage textures.
    • Note: Farmhands without the mod installed will not experience errors, but they will not be able to use the tractor or see its assets.
  5. Use the Include action to load patches from other files

    develop

    The Include action allows you to split a large content.json into multiple smaller JSON files. This is useful for organizing patches into subfiles. The included patches behave exactly as if they were written directly in the main content.json: they support tokens, conditions, and relative file paths.

    Requirements for included files:

    • Must be a .json file.
    • Must contain only a Changes field. Including other fields like ConfigSchema, CustomLocations, or DynamicTokens will cause an error.

    Path Resolution: All paths in the FromFile field are relative to the content.json file that contains the Include patch. This remains true even when an included file includes another file.

    // Example of an included file (e.g., assets/John NPC.json)
    {
        "Changes": [
            /* patches defined here like usual */
        ]
    }
  6. Create conditional transport stops

    develop

    Use the Condition field in your stop data to control when a stop is visible in the transport menu. This field accepts [game state queries]. The conditions are re-evaluated every time the menu is opened.

    Example: To make a stop only available from a specific location, use a query like: "Condition": "LOCATION_NAME Here {{ModId}}_YourRailStop"

    "Condition": "LOCATION_NAME Here {{ModId}}_YourRailStop"
  7. How Automate implements machine logic

    develop

    Since Stardew Valley does not have a native concept of 'machines' (it uses hardcoded interaction logic), Automate wraps game entities into machine instances. These instances reuse game logic where possible but reimplement it to be automatable.

    For example, the logic for kegs is handled by the KegMachine class. Automate uses an automation factory—a standardized way to map a tile, object, building, or terrain feature to a specific Machine, Container, or Connector.

    Mod authors can extend this by adding their own automation factories to enable automation for custom machines.

  8. How discovery order affects automation

    develop
    The order in which Automate discovers entities during the scanning process (the discovery order) is critical. This order determines the priority of many operations. For example, the order in which machines process their recipes is directly linked to the discovery order of the chests connected to them.
  9. Add custom machines and connectors via IAutomationFactory

    develop

    You can add new automatables (machines, containers, or connectors) by implementing the IAutomationFactory interface and registering it with the API using automate.AddFactory(new YourFactory()).

    Automate handles the core logic like entity discovery and group linking; your factory only needs to return the appropriate IAutomatable for a given entity.

    Note: If Automate already has an automatable for an entity, it will not call your factory. If you want to add new chest items as storage, use the 'add custom chest types' method instead of an automation factory to ensure they remain configurable by players.

    IAutomateAPI automate = ...;
    automate.AddFactory(new MyAutomationFactory());
  10. How EditData works in Content Patcher

    develop

    A patch using "Action": "EditData" allows you to modify fields and entries within a data asset. Content Patcher supports multiple content packs editing the same asset simultaneously.

    To use this, you must understand the hierarchy of data assets:

    1. Data Asset: The top-level container (e.g., Data/Objects).
    2. Entry: A top-level block within an asset (a key/value pair in a dictionary or an item in a list).
    3. Field: A sub-block of data located inside an entry.
    4. Target Field: An optional setting that redefines what the patch considers an "entry" by drilling down into a specific field.
  11. Important caveats when using the Token String API

    develop

    When integrating Content Patcher's token system, keep these behaviors in mind:

    • Timing: The API is not available immediately at GameLaunched. You must wait at least two ticks after GameLaunched to ensure Content Patcher has initialized its context and custom tokens.
    • Performance: Parsing is expensive. Cache your IManagedTokenString instances and reuse them instead of re-parsing the same string frequently.
    • Manual Updates: Token strings do not update automatically. If you are using a cached object, you must call tokenString.UpdateContext() to refresh the value.
    • Split-Screen: Value automatically returns the context for the current screen. However, UpdateContext() updates the context for all active screens.
  12. Use input arguments in Content Patcher tokens

    develop

    Tokens in Content Patcher can accept input arguments within the {{...}} braces to modify their behavior. Arguments can be:

    • Positional: An unnamed list of values separated by commas.
    • Named: Arguments specified using key=value syntax, where multiple values for a single key are separated by pipes (|).

    Example of mixed arguments: {{Random: a, b, c |key=some, value |example }} contains three positional values (a, b, c), a named key argument with values some and value, and a named example argument with an empty value.

    Some tokens use these to transform input. For example, the Uppercase token converts its input to uppercase:

    "Entries": {
       "fri": "It's a beautiful {{uppercase: {{season}}}} day!"
    }