Modding:Farm data

Index

This page explains how to create a custom farm type. It is an advanced guide for modders. Before reading this page, see Modding:Editing XNB files for the basic concepts.

Files to Edit

Creating a custom farm requires editing some files and adding new ones. However, you don't need any programming experience and it can be done with Content Patcher.

Farm Map

A map controls the general appearance and layout of your farm. Modding:Maps describes the basic process of creating a map. Copying and editing an existing farm map is recommended to avoid problems with missing information. The map must be added to the game files, and not replace an existing one. When testing a custom farm map, it is best to create a new save whenever you make changes to map properties or the Paths layer. Some changes to farm maps will not appear on existing saves. These properties are optional, and the game will use default values for any properties that aren't specified.

Entry Properties

These map properties can change where a player enters the farm when arriving from other locations, such as the backwoods, bus stop, or forest. Each uses the format [<int x> <int y>].

property entering from
BackwoodsEntry The backwoods
BusStopEntry The bus stop
FarmCaveEntry The farm cave
ForestEntry The cindersap forest
WarpTotemEntry Using a warp totem, or the Ginger Island farm obelisk

Building Properties

These map properties can change where some objects are positioned by default, such as the greenhouse, farmhouse, or grandpa's shrine. Each uses the format [<int x> <int y>].

property description
FarmHouseEntry Changes the position of the farmhouse. This is the tile position just below the farmhouse door, which is 3 from the top and 5 from the left of the upper left corner of the base of the farmhouse. The farmhouse is 9 x 5.
GrandpaShrineLocation Changes the position of Grandpa's shrine. It does not add the appropriate tiles or action. It is only used as a reference for displaying grandpa's note, as well as the shrine candles. This is the bottom center tile position of the shrine, where the note appears, and should be on the same tile as the appropriate action tile property. (Action: Message "Farm.1"). Even if the map property is omitted, the action tile property must be present.
GreenhouseLocation Changes the position of the greenhouse ruins. This is the the tile position of the upper left corner of the base of the greenhouse. The greenhouse is 7 x 6.
SpouseAreaLocation Changes the position of the spouse patio when you are married. This is the tile position of the upper left corner. All spouse areas are 4 x 2.
ShippingBinLocation Changes the position of the shipping bin. This is the left tile of the base of the shipping bin. Shipping bins are 2 x 1.
PetBowlLocation Changes the position of the pet's water bowl. This controls where the water bowl is displayed and where the pet sleeps when sleeping outdoors.
MailboxLocation Changes the position of the main farmhouse's mailbox. This is the tile position at the base of the mailbox. This is typically ignored, but may be used if the Farmhouse exterior is altered by a mod.

Farmhouse Interior

The starter interior layout of the farmhouse and cabins can be modified using these map properties on the farm.

property description
FarmHouseFlooring<flooring id> Changes the default flooring. For flooring from the base game, this is just the index. For custom flooring, it is [<sheet_id>:<index>]
FarmHouseWallpaper<wallpaper id> Changes the default wallpaper. For wallpaper from the base game, this is just the index. For custom wallpapers, it is [<sheet_id>:<index>]
FarmHouseStarterSeedsPosition<Tile X> <Tile Y> Changes the position of the "gift box" that appears on new saves, typically containing some starter seeds.
FarmHouseFurniture [<Furniture ID> <Tile X> <Tile Y> <Rotation>]+ Changes the initial furniture content and layout. If multiple furniture items are added to the same tile, the first one will be placed on the ground and the last one will be placed on the first one. This cannot be used to modify, move, or remove the starter bed, which is always a small bed placed at [9, 8].

Other Properties

These map properties can change other aspects of the farm, such as regenerating hardwood stumps or rock-spawning quarries.

property description
FarmFishLocationOverride <location id> <chance> Adds an alternative location id when catching fish, where the <chance> is a decimal value between 0 (never happens) and 1 (always happens). For example, FarmFishLocationOverride Mountain 0.5 adds a 50% chance of catching mountain fish instead of the normal fish for that location. The location id is case-sensitive, and matches those shown by the Debug Mode mod.
FarmOceanCrabPotOverride T Causes crab pots on the farm to catch ocean fish.
Stumps [<Tile X> <Tile Y> <unused>]+ Places hardwood stumps every morning. This is based on the upper left corner of the stumps, which are 2 x 2.
SpawnBeachFarmForage T Causes beach forage and supply crates to spawn on the farm. These will only spawn on tiles with the BeachSpawn tile property set on the Back layer and no tile on AlwaysFront, which are clear for placement.
SpawnForestFarmForage T Causes forest forage to spawn on the farm. These will only spawn on tiles with Type Grass on the Back layer and no tile on AlwaysFront, which are clear for placement.
SpawnMountainFarmOreRect <Tile X> <Tile Y> <Width> <Height> The tile area on the farm map where ores should randomly spawn (like the vanilla hilltop farm). Ores will only spawn on tiles which have the Type Dirt tile property and are clear for object placement.

Farm Type

To use a custom farm type, it must be added to the game by editing Data/AdditionalFarms. Each entry is an object with these fields:

field description
ID A unique ID value. This must be globally unique across all mods, so you should prefix your mod ID (e.g., Example.PineapplesAnywhere/PineappleFarm). You should avoid commas for compatibility with Content Patcher packs checking the {{FarmType}} token. This is not shown in-game. It should be the same as the key for this entry.
TooltipStringPath Where to get the translatable farm name and description. This must be a key in the form <asset name>:<key>; for example, Strings/UI:Farm_Description will get it from the Farm_Description entry in the Strings/UI file. The translated text must be in the form "<name>_<description>", like "Pineapple Farm_A farm shaped like a pineapple".
MapName The map asset name relative to the Maps folder. For example, Farm_Pineapple would load Maps/Farm_Pineapple.
IconTexture (optional) The asset name for a 22x20 pixel icon texture, shown on the 'New Game' and co-op join screens.
WorldMapTexture (optional) The asset name for a 131x61 pixel texture that's drawn over the farm area in the in-game world map.
ModData (optional) A string→string dictionary of mod-specific metadata for the farm, which can be accessed in C# code via Game1.GetFarmTypeModData(key).

Location Data

This step is optional. Data/Locations contains additional information about the game's locations. Each farm type has its own entry. A custom farm type can use an entry identified by Farm_<Unique_ID> to change the location data of the farm when it is used. If this location data does not exist, the location data of the standard farm layout will be used instead. This can be used to alter the forage, fish, crab pot catches, and dug up items on the farm, among other things.

For custom farms, some fields should have specific values to preserve expected behavior.

field description
DisplayName This is used to display the farm name. It should contain at least the FarmName token to be sure the farm name is shown. The standard value is

[LocalizedText Strings\\StringsFromCSFiles:MapPage.cs.11064 [EscapedText [FarmName]]]

CreateOnLoad Must be null or absent. Any other value will create duplicate locations.
CanPlantHere Should be true or absent. If false, crops can't be grown on your farm.

Example

This is an example of a Content Patcher pack adding a custom farm type with custom location data.

Data 
{
    "Changes": [
        // add farm type
        {
            "Action": "EditData",
            "Target": "Data/AdditionalFarms",
            "Entries": {
                "ExampleAuthor.PineappleFarm/PineappleFarm": { // for technical reasons, you need to specify the ID here *and* in the 'ID' field
                    "ID": "ExampleAuthor.PineappleFarm/PineappleFarm",
                    "TooltipStringPath": "Strings/UI:ExampleAuthor_PineappleFarm",
                    "MapName": "ExampleAuthor_PineappleFarm",
                    "IconTexture": "Mods/ExampleAuthor.PineappleFarm/Icon",
                    "WorldMapTexture": "Mods/ExampleAuthor.PineappleFarm/WorldMap"
                }
            }
        },

        // add farm name + description
        {
            "Action": "EditData",
            "Target": "Strings/UI",
            "Entries": {
                "ExampleAuthor_PineappleFarm": "Pineapple Farm_A farm shaped like a pineapple!" // tip: use {{i18n}} to translate it
            }
        },

        // load map
        {
            "Action": "Load",
            "Target": "Maps/ExampleAuthor_PineappleFarm",
            "FromFile": "assets/map.tmx"
        },

        // load icon
        {
            "Action": "Load",
            "Target": "Mods/ExampleAuthor.PineappleFarm/Icon, Mods/ExampleAuthor.PineappleFarm/WorldMap",
            "FromFile": "assets/{{TargetWithoutPath}}.png"
        },

        // custom location data
        {
            "Action": "EditData",
            "Target": "Data/Locations",
            "Entries": {
                "Farm_ExampleAuthor.PineappleFarm/PineappleFarm": {
                    "DisplayName": "[LocalizedText Strings\\StringsFromCSFiles:MapPage.cs.11064 [EscapedText [FarmName]]]",
                    "CanPlantHere": true,
                    "DefaultArrivalTile": {"X": 64, "Y": 15},
                    "MinDailyWeeds": 5,
                    "MaxDailyWeeds": 11,
                    "ArtifactSpots": [
                        // default artifact data
                        {
                            "Id": "Coal",
                            "ItemId": "(O)382",
                            "Chance": 0.5,
                            "MaxStack": 3
                        },
                        {
                            "Id": "Mixed_Seeds",
                            "ItemId": "(O)770",
                            "Chance": 0.1,
                            "MaxStack": 3
                        },
                        {
                            "Id": "Stone",
                            "ItemId": "(O)390",
                            "Chance": 0.25,
                            "MaxStack": 3
                        },
                        // custom artifacts
                        {
                            "Id": "Spring seeds",
                            "ItemId": "(O)495",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Spring",
                            "Precedence": 1
                        },
                        {
                            "Id": "Summer seeds",
                            "ItemId": "(O)496",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Summer",
                            "Precedence": 1
                        },
                        {
                            "Id": "Fall seeds",
                            "ItemId": "(O)497",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Fall",
                            "Precedence": 1
                        },
                        {
                            "Id": "Winter seeds",
                            "ItemId": "(O)498",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Winter",
                            "Precedence": 1
                        }
                    ]
                }
            }
        }
    ]
}