Modding:Crop data

From Stardew Valley Wiki
Revision as of 05:16, 31 May 2024 by BarleyZP (talk | contribs) (Fix broken links, update raw data)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Index

This page explains how the game stores and parses crops data. This is an advanced guide for mod developers.

Raw data

Crop data is stored in Data\Crops.xnb, which can be unpacked for editing. Here's a portion of the raw data as of 1.6.8 for reference:

Data 
{
  "472": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      1,
      1,
      1
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "24",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 0,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  },
  "473": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      1,
      1,
      3,
      4
    ],
    "RegrowDays": 3,
    "IsRaised": true,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "188",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 1,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  },
  "474": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      2,
      4,
      4,
      1
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "190",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 2,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  },
  "475": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      1,
      1,
      2,
      1
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "192",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.2,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 3,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  },
  "476": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      1,
      1,
      1
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "248",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 4,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  },
  "273": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      2,
      2,
      3
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": true,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "271",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.1,
    "ExtraHarvestChance": 0.1,
    "HarvestMethod": "Scythe",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 34,
    "CountForMonoculture": false,
    "CountForPolyculture": false,
    "CustomFields": null
  },
  "831": {
    "Seasons": [
      "Summer"
    ],
    "DaysInPhase": [
      1,
      2,
      3,
      4
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": true,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "830",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 42,
    "CountForMonoculture": false,
    "CountForPolyculture": false,
    "CustomFields": null
  },
  "477": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      1,
      2,
      2,
      1
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "250",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Scythe",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 5,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  },
  "478": {
    "Seasons": [
      "Spring"
    ],
    "DaysInPhase": [
      2,
      2,
      2,
      3,
      4
    ],
    "RegrowDays": -1,
    "IsRaised": false,
    "IsPaddyCrop": false,
    "NeedsWatering": true,
    "PlantableLocationRules": null,
    "HarvestItemId": "252",
    "HarvestMinStack": 1,
    "HarvestMaxStack": 1,
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
    "ExtraHarvestChance": 0.0,
    "HarvestMethod": "Grab",
    "HarvestMinQuality": 0,
    "HarvestMaxQuality": null,
    "TintColors": [],
    "Texture": "TileSheets\\crops",
    "SpriteIndex": 6,
    "CountForMonoculture": true,
    "CountForPolyculture": true,
    "CustomFields": null
  }
}

Format

The asset Data\Crops consists of a string → model lookup, where...

  • The key is the unqualified item ID for the seed item.
  • The value is model with the fields listed below.
field effect
Growth
Seasons The seasons in which this crop can grow (any combination of spring, summer, fall, and winter).
DaysInPhase The number of days in each visual step of growth before the crop is harvestable. Each step corresponds to a sprite in the crop's row (see SpriteIndex).

For example, a crop with "DaysInPhase": [ 1, 1, 1, 1 ] will grow from seed to harvestable in 4 days, moving to the next sprite in the row each day.

RegrowDays (Optional) The number of days before the crop regrows after harvesting, or -1 if it can't regrow. The crop will keep the full-grown sprite (i.e. the last phase in DaysInPhase) during this time. Default -1.
IsRaised (Optional) Whether this is a raised crop on a trellis that can't be walked through. Default false.
IsPaddyCrop (Optional) Whether this crop can be planted near water for a unique paddy dirt texture, faster growth time, and auto-watering. For example, rice and taro are paddy crops. Default false.
NeedsWatering (Optional) Whether this crop needs to be watered to grow (e.g. fiber seeds don't). Default true.
Harvest
HarvestItemId The item ID produced when this crop is harvested.
HarvestMethod (Optional) How the crop can be harvested. This can be Grab (crop is harvested by hand) or Scythe (harvested with a scythe). Default Grab.
HarvestMinStack
HarvestMaxStack
(Optional) The minimum and maximum number of HarvestItemId to produce (before HarvestMaxIncreasePerFarmingLevel and ExtraHarvestChance are applied). A value within this range (inclusive) will be randomly chosen each time the crop is harvested. The minimum defaults to 1, and the maximum defaults to the minimum.
HarvestMinQuality
HarvestMaxQuality
(Optional) If set, the minimum and maximum quality of the harvest crop. These fields set a constraint that's applied after the quality is calculated normally, they don't affect the initial quality logic.
HarvestMaxIncreasePerFarmingLevel (Optional) The number of extra harvests to produce per farming level. This is rounded down to the nearest integer and added to HarvestMaxStack. Defaults to 0.

For example, a value of 0.2 is equivalent to +1 max at level 5 and +2 at level 10.

ExtraHarvestChance (Optional) The probability that harvesting the crop will produce extra harvest items, as a value between 0 (never) and 0.9 (nearly always). This is repeatedly rolled until it fails, then the number of successful rolls is added to the produced count. For example, tomatoes use 0.05. Default 0. This is a geometric series with expected value of 1/(1-ExtraHarvestChance) - 1, so it will grow faster than you expect it should. For example, with a value of 0.9, this field has an expected value of nine additional crops.
Appearance
Texture The asset name for the texture (under the game's Content folder) containing the crop sprite. For example, the vanilla crops use TileSheets\crops.
SpriteIndex (Optional) The index of this crop in the Texture, one crop per row, where 0 is the top row. Default 0.
TintColors (Optional) The colors with which to tint the sprite when drawn (e.g. for colored flowers). A random color from the list will be chosen for each crop. See color format. Default none.
Achievements
CountForMonoculture (Optional) Whether the player can ship 300 of this crop's harvest item to unlock the monoculture achievement. Default false.
CountForPolyculture (Optional) Whether the player must ship 15 of this crop's harvest item (along with any other required crops) to unlock the polyculture achievement. Default false.
Advanced
PlantableLocationRules (Optional) The rules to decide which locations you can plant the seed in, if applicable. The first matching rule is used. This can override location checks (e.g. crops being limited to the farm), but not built-in requirements like crops needing dirt.

This consists of a list of models with these fields:

field effect
Id The unique string ID for this entry within the list.
Result Indicates whether the seed can be planted in a location if this entry is selected. The possible values are:
  • Default: the seed can be planted if the location normally allows it. This can be used to stop processing further rules, and/or set a custom DeniedMessage.
  • Allow: the seed can be planted here, regardless of whether the location normally allows it.
  • Deny: the seed can't be planted here, regardless of whether the location normally allows it.
Condition (Optional) A game state query which indicates whether this entry applies. Default true.
PlantedIn (Optional) The planting context to apply this rule for. The possible values are Ground (planted directly in dirt), GardenPot (planted in a garden pot), or Any. Default Any.
DeniedMessage (Optional) If this rule prevents planting the seed, the tokenizable string to show to the player (or null to default to the normal behavior for the context). This also applies when the Result is Default, if that causes the planting to be denied.
CustomFields The custom fields for this entry.

For example, this adds a custom cucumber crop (assuming you've already added custom items for cucumber seeds and cucumber):

{
    "Format": "2.0.0",
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/Crops",
            "Entries": {
                "Example.Id_CucumberSeeds": {
                    "Seasons": [ "summer" ],
                    "DaysInPhase": [ 1, 2, 2, 2 ], // grows in 7 days with four growing sprites
                    "HarvestItemId": "Example.Id_Cucumber",
                    "Texture": "{{InternalAssetKey: assets/crops.png}}",
                    "SpriteIndex": 0
                }
            }
        }
    ]
}