Difference between revisions of "Modding:Crop data"

From Stardew Valley Wiki
Jump to navigation Jump to search
(→‎Chance for Extra Harvest: code correction)
(Fix broken links, update raw data)
 
(27 intermediate revisions by 11 users not shown)
Line 4: Line 4:
  
 
==Raw data==
 
==Raw data==
Crops data is stored in <tt>Content\Data\Crops.xnb</tt>, which can be [[Modding:Creating an XNB mod#unpacking|unpacked using XNB Extract]]. Here's the raw data (as of v1.2) 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:
  
<source lang="yaml">
+
{{collapse|Data|content=<syntaxhighlight lang="json">
299: "1 2 2 2/fall/39/300/-1/1/false/false/false" #!String
+
{
301: "1 1 2 3 3/fall/38/398/3/0/true 1 2 6 0/true/false" #!String
+
  "472": {
302: "1 1 2 3 4/summer/37/304/1/0/true 1 2 6 0/true/false" #!String
+
    "Seasons": [
347: "2 4 6 6 6/fall/32/417/-1/0/false/false/false" #!String
+
      "Spring"
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" #!String
+
    ],
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" #!String
+
    "DaysInPhase": [
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" #!String
+
      1,
431: "1 2 3 2/summer fall/30/421/-1/0/false/false/false" #!String
+
      1,
433: "1 2 2 3 2/spring summer/40/433/2/0/true 4 6 10 .02/false/false" #!String
+
      1,
453: "1 2 2 2/summer/28/376/-1/0/false/false/true 255 0 0 254 254 254 255 170 0" #!String
+
      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" #!String
+
    ],
472: "1 1 1 1/spring/0/24/-1/0/false/false/false" #!String
+
    "RegrowDays": -1,
473: "1 1 1 3 4/spring/1/188/3/0/true 1 2 6 0/true/false" #!String
+
    "IsRaised": false,
474: "1 2 4 4 1/spring/2/190/-1/0/false/false/false" #!String
+
    "IsPaddyCrop": false,
475: "1 1 1 2 1/spring/3/192/-1/0/true 1 2 8 .2/false/false" #!String
+
    "NeedsWatering": true,
476: "1 1 1 1/spring/4/248/-1/0/false/false/false" #!String
+
    "PlantableLocationRules": null,
477: "1 2 2 1/spring/5/250/-1/1/false/false/false" #!String
+
    "HarvestItemId": "24",
478: "2 2 2 3 4/spring/6/252/-1/0/false/false/false" #!String
+
    "HarvestMinStack": 1,
479: "1 2 3 3 3/summer/7/254/-1/0/false/false/false" #!String
+
    "HarvestMaxStack": 1,
480: "2 2 2 2 3/summer/8/256/4/0/true 1 1 6 .05/false/false" #!String
+
    "HarvestMaxIncreasePerFarmingLevel": 0.0,
481: "1 3 3 4 2/summer/9/258/4/0/true 3 5 5 .02/false/false" #!String
+
    "ExtraHarvestChance": 0.0,
482: "1 1 1 1 1/summer/10/260/3/0/true 1 1 5 .03/false/false" #!String
+
    "HarvestMethod": "Grab",
483: "1 1 1 1/summer fall/11/262/-1/1/false/false/false" #!String
+
    "HarvestMinQuality": 0,
484: "2 1 2 1/summer/12/264/-1/0/false/false/false" #!String
+
    "HarvestMaxQuality": null,
485: "2 1 2 2 2/summer/13/266/-1/0/false/false/false" #!String
+
    "TintColors": [],
486: "2 3 2 3 3/summer/14/268/-1/0/false/false/false" #!String
+
    "Texture": "TileSheets\\crops",
487: "2 3 3 3 3/summer fall/15/270/4/0/true 1 2 5 0/false/false" #!String
+
    "SpriteIndex": 0,
488: "1 1 1 1 1/fall/16/272/5/0/true 1 2 10 .002/false/false" #!String
+
    "CountForMonoculture": true,
489: "2 2 1 2 1/fall/17/274/-1/0/false/false/false" #!String
+
    "CountForPolyculture": true,
490: "1 2 3 4 3/fall/18/276/-1/0/false/false/false" #!String
+
    "CustomFields": null
491: "1 1 1 1/fall/19/278/-1/0/false/false/false" #!String
+
  },
492: "1 3 3 3/fall/20/280/-1/0/false/false/false" #!String
+
  "473": {
493: "1 2 1 1 2/fall/21/282/5/0/true 2 6 5 .1/false/false" #!String
+
    "Seasons": [
494: "1 1 2 2/fall/22/284/-1/0/false/false/false" #!String
+
      "Spring"
495: "3 4/spring/23/16/-1/0/false/false/false" #!String
+
    ],
496: "3 4/summer/23/396/-1/0/false/false/false" #!String
+
    "DaysInPhase": [
497: "3 4/fall/23/404/-1/0/false/false/false" #!String
+
      1,
498: "3 4/winter/23/412/-1/0/false/false/false" #!String
+
      1,
499: "2 7 7 7 5/spring summer fall/24/454/7/0/false/false/false" #!String
+
      1,
745: "1 1 2 2 2/spring/36/400/4/0/true 1 1 5 .02/false/false" #!String
+
      3,
</source>
+
      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
 +
  }
 +
}
 +
</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
 
 
|-
 
|-
| Key
+
!colspan="2"| Growth
| Seed Index <small>(from [[Modding:Object data|ObjectInformation.xnb]])</small>
 
| 473 <small>''(Bean Starter)''</small>
 
| 455 <small>''(Spangle Seeds)''</small>
 
 
|-
 
|-
| 0
+
| <samp>Seasons</samp>
| Days in each stage of growth
+
| The seasons in which this crop can grow (any combination of <samp>spring</samp>, <samp>summer</samp>, <samp>fall</samp>, and <samp>winter</samp>).
| 1 1 1 3 4
 
| 1 2 3 2
 
 
|-
 
|-
| 1
+
| <samp>DaysInPhase</samp>
| Growth Season(s)
+
| 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>).
| spring
+
 
| summer
+
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.
 
|-
 
|-
| 2
+
| <samp>RegrowDays</samp>
| Row in Sprite Sheet <small>(<tt>Content\TileSheets\Crops.xnb</tt>)</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.
| 1
 
| 29
 
 
|-
 
|-
| 3
+
| <samp>IsRaised</samp>
| Index of Harvest <small>(from [[Modding:Object data|ObjectInformation.xnb]])</small>
+
| ''(Optional)'' Whether this is a raised crop on a trellis that can't be walked through. Default false.
| 188 <small>''(Green Bean)''</small>
 
| 593 <small>''(Summer Spangle)''</small>
 
 
|-
 
|-
| 4
+
| <samp>IsPaddyCrop</samp>
| Regrow after Harvest
+
| ''(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.
| 3
 
| -1
 
 
|-
 
|-
| 5
+
| <samp>NeedsWatering</samp>
| Harvest Method
+
| ''(Optional)'' Whether this crop needs to be watered to grow (e.g. [[Fiber Seeds|fiber seeds]] don't). Default true.
| 0
 
| 0
 
 
|-
 
|-
| 6
+
!colspan="2"| Harvest
| Chance for Extra Harvest
 
| true 1 2 6 0
 
| false
 
 
|-
 
|-
| 7
+
| <samp>HarvestItemId</samp>
| Raised Seeds
+
| The item ID produced when this crop is harvested.
| true
 
| false
 
 
|-
 
|-
| 8
+
| <samp>HarvestMethod</samp>
| Tint Color
+
| ''(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>.
| false
+
|-
| true 0 208 255 99 255 210 255 212 0 255 144 122 255 0 238 206 91 255
+
| <samp>HarvestMinStack</samp><br /><samp>HarvestMaxStack</samp>
|}
+
| ''(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.
 +
|-
 +
| <samp>HarvestMinQuality</samp><br /><samp>HarvestMaxQuality</samp>
 +
| ''(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.
 +
|-
 +
| <samp>HarvestMaxIncreasePerFarmingLevel</samp>
 +
| ''(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.
  
===Regrow after Harvest===
+
For example, a value of 0.2 is equivalent to +1 max at level 5 and +2 at level 10.
Either -1 for no regrowth, or number of days until regrowth.
+
|-
 +
| <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.
  
===Harvest Method===
+
This consists of a list of models with these fields:
1 for Scythe, 0 for all others
 
  
===Chance for Extra Harvest===
+
{| class="wikitable"
If this value is true, then the numbers that follow are parsed as:
+
|-
#minHarvest
+
! field
#maxHarvest
+
! effect
#maxHarvestIncreasePerFarmingLevel
+
|-
#chanceForExtraCrops
+
| <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.
 +
|}
  
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:
+
For example, this adds a custom cucumber crop (assuming you've already added [[Modding:Items|custom items]] for cucumber seeds and cucumber):
 +
{{#tag:syntaxhighlight|<nowiki>
 +
{
 +
    "Format": "</nowiki>{{Content Patcher version}}<nowiki>",
 +
    "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
 +
                }
 +
            }
 +
        }
 +
    ]
 +
}</nowiki>|lang=javascript}}
  
<source lang="C#">
+
[[Category:Modding]]
if (this.minHarvest > 1 || this.maxHarvest > 1)
 
    num = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel));
 
 
 
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;
 
</source>
 
 
 
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]]
+
[[fr:Modding:Données des récoltes]]
 +
[[ru:Модификации:Культуры]]
 +
[[zh:模组:农作物数据]]

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