Difference between revisions of "Modding:Crop data"

From Stardew Valley Wiki
Jump to navigation Jump to search
m (Replace deprecated <source> tags with <syntaxhighlight> tags)
(Fix broken links, update raw data)
 
(13 intermediate revisions by 7 users not shown)
Line 4: Line 4:
  
 
==Raw data==
 
==Raw data==
Crop data is stored in <tt>Content\Data\Crops.xnb</tt>, which can be [[Modding:Editing XNB files#unpacking|unpacked for editing]]. Here's the raw data as of {{version|1.5.1}} for reference:
+
Crop data is stored in <samp>Data\Crops.xnb</samp>, which can be [[Modding:Editing XNB files#unpacking|unpacked for editing]]. Here's a portion of the raw data as of {{version|1.6.8}} for reference:
  
 
{{collapse|Data|content=<syntaxhighlight lang="json">
 
{{collapse|Data|content=<syntaxhighlight lang="json">
 
{
 
{
   "472": "1 1 1 1/spring/0/24/-1/0/false/false/false",
+
   "472": {
  "473": "1 1 1 3 4/spring/1/188/3/0/false/true/false",
+
    "Seasons": [
  "474": "1 2 4 4 1/spring/2/190/-1/0/false/false/false",
+
      "Spring"
   "475": "1 1 1 2 1/spring/3/192/-1/0/true 1 1 0 .2/false/false",
+
    ],
  "476": "1 1 1 1/spring/4/248/-1/0/false/false/false",
+
    "DaysInPhase": [
  "273": "1 2 2 3/spring/34/271/-1/1/true 1 1 10 .1/false/false",
+
      1,
   "831": "1 2 3 4/summer/42/830/-1/0/false/false/false",
+
      1,
  "477": "1 2 2 1/spring/5/250/-1/1/false/false/false",
+
      1,
  "478": "2 2 2 3 4/spring/6/252/-1/0/false/false/false",
+
      1
  "745": "1 1 2 2 2/spring/36/400/4/0/true 1 1 0 .02/false/false",
+
    ],
   "479": "1 2 3 3 3/summer/7/254/-1/0/false/false/false",
+
    "RegrowDays": -1,
  "480": "2 2 2 2 3/summer/8/256/4/0/true 1 1 0 .05/false/false",
+
    "IsRaised": false,
  "481": "1 3 3 4 2/summer/9/258/4/0/true 3 3 0 .02/false/false",
+
    "IsPaddyCrop": false,
  "482": "1 1 1 1 1/summer/10/260/3/0/true 1 1 0 .03/false/false",
+
    "NeedsWatering": true,
   "483": "1 1 1 1/summer fall/11/262/-1/1/false/false/false",
+
    "PlantableLocationRules": null,
  "484": "2 1 2 1/summer/12/264/-1/0/false/false/false",
+
    "HarvestItemId": "24",
  "485": "2 1 2 2 2/summer/13/266/-1/0/false/false/false",
+
    "HarvestMinStack": 1,
  "486": "2 3 2 3 3/summer/14/268/-1/0/false/false/false",
+
    "HarvestMaxStack": 1,
  "833": "1 3 3 4 3/summer/43/832/7/0/false/false/false",
+
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
  "433": "1 2 2 3 2/spring summer/40/433/2/0/true 4 4 0 .02/false/false",
+
    "ExtraHarvestChance": 0.0,
  "802": "2 2 2 3 3/spring summer fall winter/41/90/3/0/false/false/false",
+
    "HarvestMethod": "Grab",
   "487": "2 3 3 3 3/summer fall/15/270/4/0/false/false/false",
+
    "HarvestMinQuality": 0,
  "302": "1 1 2 3 4/summer/37/304/1/0/false/true/false",
+
    "HarvestMaxQuality": null,
  "301": "1 1 2 3 3/fall/38/398/3/0/false/true/false",
+
    "TintColors": [],
  "299": "1 2 2 2/fall/39/300/-1/1/false/false/false",
+
    "Texture": "TileSheets\\crops",
  "488": "1 1 1 1 1/fall/16/272/5/0/true 1 1 0 .002/false/false",
+
    "SpriteIndex": 0,
  "489": "2 2 1 2 1/fall/17/274/-1/0/false/false/false",
+
    "CountForMonoculture": true,
   "490": "1 2 3 4 3/fall/18/276/-1/0/false/false/false",
+
    "CountForPolyculture": true,
  "491": "1 1 1 1/fall/19/278/-1/0/false/false/false",
+
    "CustomFields": null
  "492": "1 3 3 3/fall/20/280/-1/0/false/false/false",
+
  },
  "493": "1 2 1 1 2/fall/21/282/5/0/true 2 2 0 .1/false/false",
+
   "473": {
  "494": "1 1 2 2/fall/22/284/-1/0/false/false/false",
+
    "Seasons": [
  "499": "2 7 7 7 5/spring summer fall/24/454/7/0/false/false/false",
+
      "Spring"
  "427": "1 1 2 2/spring/26/591/-1/0/false/false/true 255 186 255 223 191 255 255 246 0 255 80 0 255 158 193",
+
    ],
   "429": "1 2 2 2/spring/27/597/-1/0/false/false/true 35 127 255 109 131 255 112 207 255 191 228 255 94 121 255 40 150 255",
+
    "DaysInPhase": [
  "453": "1 2 2 2/summer/28/376/-1/0/false/false/true 255 0 0 254 254 254 255 170 0",
+
      1,
  "455": "1 2 3 2/summer/29/593/-1/0/false/false/true 0 208 255 99 255 210 255 212 0 255 144 122 255 0 238 206 91 255",
+
      1,
  "431": "1 2 3 2/summer fall/30/421/-1/0/false/false/false",
+
      1,
  "425": "1 4 4 3/fall/31/595/-1/0/false/false/true 187 0 255 119 137 255 71 227 255 255 127 144 205 178 255 140 119 255",
+
      3,
   "347": "2 4 6 6 6/fall/32/417/-1/0/false/false/false",
+
      4
  "495": "3 4/spring/23/16/-1/0/false/false/false",
+
    ],
  "496": "3 4/summer/23/396/-1/0/false/false/false",
+
    "RegrowDays": 3,
  "497": "3 4/fall/23/404/-1/0/false/false/false",
+
    "IsRaised": true,
  "498": "3 4/winter/23/412/-1/0/false/false/false",
+
    "IsPaddyCrop": false,
  "885": "1 2 2 2/spring summer fall winter/44/771/-1/1/true 4 7 0 .01/false/false",
+
    "NeedsWatering": true,
  "890": "1 1 1 1/spring summer fall winter/47/889/-1/0/false/false/false"
+
    "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
 +
  }
 
}
 
}
 
</syntaxhighlight>}}
 
</syntaxhighlight>}}
  
 
==Format==
 
==Format==
 +
 +
The asset <samp>Data\Crops</samp> consists of a string → model lookup, where...
 +
* The key is the unqualified [[Modding:Common_data_field_types#Item_ID|item ID]] for the seed item.
 +
* The value is model with the fields listed below.
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Index
+
! field
! Field
+
! effect
! colspan="2"|Example Value
+
|-
 +
!colspan="2"| Growth
 +
|-
 +
| <samp>Seasons</samp>
 +
| The seasons in which this crop can grow (any combination of <samp>spring</samp>, <samp>summer</samp>, <samp>fall</samp>, and <samp>winter</samp>).
 +
|-
 +
| <samp>DaysInPhase</samp>
 +
| 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 <samp>SpriteIndex</samp>).
 +
 
 +
For example, a crop with <code>"DaysInPhase": [ 1, 1, 1, 1 ]</code> will grow from seed to harvestable in 4 days, moving to the next sprite in the row each day.
 
|-
 
|-
| Key
+
| <samp>RegrowDays</samp>
| Seed Index <small>(from [[Modding:Object data|ObjectInformation.xnb]])</small>
+
| ''(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 <samp>DaysInPhase</samp>) during this time. Default -1.
| 473 <small>''(Bean Starter)''</small>
 
| 455 <small>''(Spangle Seeds)''</small>
 
 
|-
 
|-
| 0
+
| <samp>IsRaised</samp>
| Days in each stage of growth
+
| ''(Optional)'' Whether this is a raised crop on a trellis that can't be walked through. Default false.
| 1 1 1 3 4
 
| 1 2 3 2
 
 
|-
 
|-
| 1
+
| <samp>IsPaddyCrop</samp>
| Growth Season(s)
+
| ''(Optional)'' Whether this crop can be planted near water for a unique paddy dirt texture, faster growth time, and auto-watering. For example, [[Rice Shoot|rice]] and [[Taro Root|taro]] are paddy crops. Default false.
| spring
 
| summer
 
 
|-
 
|-
| 2
+
| <samp>NeedsWatering</samp>
| Index in Sprite Sheet <small>(<tt>Content\TileSheets\Crops.xnb</tt>)</small>
+
| ''(Optional)'' Whether this crop needs to be watered to grow (e.g. [[Fiber Seeds|fiber seeds]] don't). Default true.
| 1
 
| 29
 
 
|-
 
|-
| 3
+
!colspan="2"| Harvest
| Index of Harvest <small>(from [[Modding:Object data|ObjectInformation.xnb]])</small>
 
| 188 <small>''(Green Bean)''</small>
 
| 593 <small>''(Summer Spangle)''</small>
 
 
|-
 
|-
| 4
+
| <samp>HarvestItemId</samp>
| Regrow after Harvest
+
| The item ID produced when this crop is harvested.
| 3
 
| -1
 
 
|-
 
|-
| 5
+
| <samp>HarvestMethod</samp>
| Harvest Method
+
| ''(Optional)'' How the crop can be harvested. This can be <samp>Grab</samp> (crop is harvested by hand) or <samp>Scythe</samp> (harvested with a [[scythe]]). Default <samp>Grab</samp>.
| 0
 
| 0
 
 
|-
 
|-
| 6
+
| <samp>HarvestMinStack</samp><br /><samp>HarvestMaxStack</samp>
| Chance for Extra Harvest
+
| ''(Optional)'' The minimum and maximum number of <samp>HarvestItemId</samp> to produce (before <samp>HarvestMaxIncreasePerFarmingLevel</samp> and <samp>ExtraHarvestChance</samp> 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.
| true 1 2 6 0
 
| false
 
 
|-
 
|-
| 7
+
| <samp>HarvestMinQuality</samp><br /><samp>HarvestMaxQuality</samp>
| Raised Seeds
+
| ''(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.
| true
 
| false
 
 
|-
 
|-
| 8
+
| <samp>HarvestMaxIncreasePerFarmingLevel</samp>
| Tint Color
+
| ''(Optional)'' The number of extra harvests to produce per farming level. This is rounded down to the nearest integer and added to <samp>HarvestMaxStack</samp>. Defaults to 0.
| false
 
| true 0 208 255 99 255 210 255 212 0 255 144 122 255 0 238 206 91 255
 
|}
 
  
===Days in each stage of growth===
+
For example, a value of 0.2 is equivalent to +1 max at level 5 and +2 at level 10.
The number of days in each visual step of growth. The final stage will be harvestable after the specified number of days.
+
|-
 +
| <samp>ExtraHarvestChance</samp>
 +
| ''(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, [[tomato]]es use 0.05. Default 0. This is [https://www.desmos.com/calculator/ok9c2tw6o5 a geometric series with expected value] of <samp>1/(1-ExtraHarvestChance) - 1</samp>, so it will grow faster than you expect it should. For example, with a value of <samp>0.9</samp>, this field has an expected value of nine additional crops.
 +
|-
 +
!colspan="2"| Appearance
 +
|-
 +
| <samp>Texture</samp>
 +
| The asset name for the texture (under the game's <samp>Content</samp> folder) containing the crop sprite. For example, the vanilla crops use <samp>TileSheets\crops</samp>.
 +
|-
 +
| <samp>SpriteIndex</samp>
 +
| ''(Optional)'' The index of this crop in the <samp>Texture</samp>, one crop per row, where 0 is the top row. Default 0.
 +
|-
 +
| <samp>TintColors</samp>
 +
| ''(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 fields|color format]]. Default none.
 +
|-
 +
!colspan="2"| Achievements
 +
|-
 +
| <samp>CountForMonoculture</samp>
 +
| ''(Optional)'' Whether the player can ship 300 of this crop's harvest item to unlock the monoculture [[achievements|achievement]]. Default false.
 +
|-
 +
| <samp>CountForPolyculture</samp>
 +
| ''(Optional)'' Whether the player must ship 15 of this crop's harvest item (along with any other required crops) to unlock the polyculture [[achievements|achievement]]. Default false.
 +
|-
 +
!colspan="2"| Advanced
 +
|-
 +
| <samp>PlantableLocationRules</samp>
 +
| ''(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.
  
===Regrow after harvest===
+
This consists of a list of models with these fields:
Either -1 for no regrowth, or the number of days until the crop can be harvested again.
 
  
===Harvest method===
+
{| class="wikitable"
1 for Scythe, 0 for all others
+
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>Id</samp>
 +
| The [[Modding:Common data field types#Unique string ID|unique string ID]] for this entry within the list.
 +
|-
 +
| <samp>Result</samp>
 +
| Indicates whether the seed can be planted in a location if this entry is selected. The possible values are:
 +
* <samp>Default</samp>: 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 <samp>DeniedMessage</samp>.
 +
* <samp>Allow</samp>: the seed can be planted here, regardless of whether the location normally allows it.
 +
* <samp>Deny</samp>: the seed can't be planted here, regardless of whether the location normally allows it.
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this entry applies. Default true.
 +
|-
 +
| <samp>PlantedIn</samp>
 +
| ''(Optional)'' The planting context to apply this rule for. The possible values are <samp>Ground</samp> (planted directly in dirt), <samp>GardenPot</samp> (planted in a [[Garden Pot|garden pot]]), or <samp>Any</samp>. Default <samp>Any</samp>.
 +
|-
 +
| <samp>DeniedMessage</samp>
 +
| ''(Optional)'' If this rule prevents planting the seed, the tokenizable string to show to the player (or <samp>null</samp> to default to the normal behavior for the context). This also applies when the <samp>Result</samp> is <samp>Default</samp>, if that causes the planting to be denied.
 +
|}
 +
|-
 +
| <samp>CustomFields</samp>
 +
| The [[Modding:Common_data_field_types#Custom_fields|custom fields]] for this entry.
 +
|}
  
===Chance for extra harvest===
+
For example, this adds a custom cucumber crop (assuming you've already added [[Modding:Items|custom items]] for cucumber seeds and cucumber):
If this value is true, then the numbers that follow are parsed as:
+
{{#tag:syntaxhighlight|<nowiki>
#minHarvest
+
{
#maxHarvest
+
    "Format": "</nowiki>{{Content Patcher version}}<nowiki>",
#maxHarvestIncreasePerFarmingLevel
+
    "Changes": [
#chanceForExtraCrops
+
        {
 +
            "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
 +
                }
 +
            }
 +
        }
 +
    ]
 +
}</nowiki>|lang=javascript}}
  
The game determines the number of crops gained at a single harvest using the following code from <tt>Crops.cs::harvest()</tt>, where <tt>num</tt> is the number of crops gained:
+
[[Category:Modding]]
  
<syntaxhighlight lang="C#">
+
[[fr:Modding:Données des récoltes]]
if (this.minHarvest > 1 || this.maxHarvest > 1)
+
[[ru:Модификации:Культуры]]
    num = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel));
+
[[zh:模组:农作物数据]]
 
 
if (this.chanceForExtraCrops > 0.0)
 
    while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops))
 
        num++;
 
 
 
if (random.NextDouble() < (double)Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
 
    num *= 2;
 
</syntaxhighlight>
 
 
 
The result (''i.e.'', <tt>num</tt>) of <code>random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel))</code> is '''always the minHarvest''', for 2 reasons.
 
#Taking the <tt>Math.Min</tt> of (<tt>minHarvest + 1</tt>) and (<tt>this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel</tt>) always results in (<tt>minHarvest + 1</tt>)
 
#<tt>random.Next</tt> uses an inclusive lower bound and an exclusive upper bound, so it is effectively calculating a random number between <tt>minHarvest</tt> and <tt>minHarvest</tt>
 
Therefore, as of v1.2, only 3 seeds always give more than one crop per harvest, and that number is equal to the minHarvest:
 
*Coffee Bean (433) -- 4 Beans
 
*Blueberry Seeds (481) -- 3 Blueberries
 
*Cranberry Seeds (493) -- 2 Cranberries
 
 
 
The value in <tt>chanceForExtraCrops</tt> may add additional crops to a harvest, calculated independently of the other 3 variables.  For example, each harvest of a Potato Seed (475) has &#8776;20% chance of yielding an extra potato, in addition to the one Potato given as standard harvest.  Each harvest of a Blueberry Seed (481) has &#8776;2% chance of yielding an extra Blueberry, in addition to the 3 Blueberries given as standard harvest.
 
 
 
===Raised seeds===
 
True for trellis crops (Grapes, Hops, Green Beans), false for all others.
 
 
 
===Tint color===
 
If Tint Color is true, a string of rgb() values follows.  In the example above, Summer Spangle can be one of 6 different colors:
 
*rgb(0, 208, 255)
 
*rgb(99, 255, 210)
 
*rgb(255, 212, 0)
 
*rgb(255, 144, 122)
 
*rgb(255, 0, 238)
 
*rgb(206, 91, 255)
 
 
 
[[Category:Modding]]
 

Latest revision as of 05:16, 31 May 2024

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
                }
            }
        }
    ]
}