Difference between revisions of "Modding:Crop data"

From Stardew Valley Wiki
Jump to navigation Jump to search
(remove template:stub)
(formatting)
 
(27 intermediate revisions by 10 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>Content\Data\Crops.xnb</samp>, which can be [[Modding:Editing XNB files#unpacking|unpacked for editing]]. Here's the raw data as of {{version|1.5.1}} 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": "1 1 1 1/spring/0/24/-1/0/false/false/false",
302: "1 1 2 3 4/summer/37/304/1/0/true 1 2 6 0/true/false" #!String
+
  "473": "1 1 1 3 4/spring/1/188/3/0/false/true/false",
347: "2 4 6 6 6/fall/32/417/-1/0/false/false/false" #!String
+
  "474": "1 2 4 4 1/spring/2/190/-1/0/false/false/false",
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
+
  "475": "1 1 1 2 1/spring/3/192/-1/0/true 1 1 0 .2/false/false",
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
+
  "476": "1 1 1 1/spring/4/248/-1/0/false/false/false",
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
+
  "273": "1 2 2 3/spring/34/271/-1/1/true 1 1 10 .1/false/false",
431: "1 2 3 2/summer fall/30/421/-1/0/false/false/false" #!String
+
  "831": "1 2 3 4/summer/42/830/-1/0/false/false/false",
433: "1 2 2 3 2/spring summer/40/433/2/0/true 4 6 10 .02/false/false" #!String
+
  "477": "1 2 2 1/spring/5/250/-1/1/false/false/false",
453: "1 2 2 2/summer/28/376/-1/0/false/false/true 255 0 0 254 254 254 255 170 0" #!String
+
  "478": "2 2 2 3 4/spring/6/252/-1/0/false/false/false",
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
+
  "745": "1 1 2 2 2/spring/36/400/4/0/true 1 1 0 .02/false/false",
472: "1 1 1 1/spring/0/24/-1/0/false/false/false" #!String
+
  "479": "1 2 3 3 3/summer/7/254/-1/0/false/false/false",
473: "1 1 1 3 4/spring/1/188/3/0/true 1 2 6 0/true/false" #!String
+
  "480": "2 2 2 2 3/summer/8/256/4/0/true 1 1 0 .05/false/false",
474: "1 2 4 4 1/spring/2/190/-1/0/false/false/false" #!String
+
  "481": "1 3 3 4 2/summer/9/258/4/0/true 3 3 0 .02/false/false",
475: "1 1 1 2 1/spring/3/192/-1/0/true 1 2 8 .2/false/false" #!String
+
  "482": "1 1 1 1 1/summer/10/260/3/0/true 1 1 0 .03/false/false",
476: "1 1 1 1/spring/4/248/-1/0/false/false/false" #!String
+
  "483": "1 1 1 1/summer fall/11/262/-1/1/false/false/false",
477: "1 2 2 1/spring/5/250/-1/1/false/false/false" #!String
+
  "484": "2 1 2 1/summer/12/264/-1/0/false/false/false",
478: "2 2 2 3 4/spring/6/252/-1/0/false/false/false" #!String
+
  "485": "2 1 2 2 2/summer/13/266/-1/0/false/false/false",
479: "1 2 3 3 3/summer/7/254/-1/0/false/false/false" #!String
+
  "486": "2 3 2 3 3/summer/14/268/-1/0/false/false/false",
480: "2 2 2 2 3/summer/8/256/4/0/true 1 1 6 .05/false/false" #!String
+
  "833": "1 3 3 4 3/summer/43/832/7/0/false/false/false",
481: "1 3 3 4 2/summer/9/258/4/0/true 3 5 5 .02/false/false" #!String
+
  "433": "1 2 2 3 2/spring summer/40/433/2/0/true 4 4 0 .02/false/false",
482: "1 1 1 1 1/summer/10/260/3/0/true 1 1 5 .03/false/false" #!String
+
  "802": "2 2 2 3 3/spring summer fall winter/41/90/3/0/false/false/false",
483: "1 1 1 1/summer fall/11/262/-1/1/false/false/false" #!String
+
  "487": "2 3 3 3 3/summer fall/15/270/4/0/false/false/false",
484: "2 1 2 1/summer/12/264/-1/0/false/false/false" #!String
+
  "302": "1 1 2 3 4/summer/37/304/1/0/false/true/false",
485: "2 1 2 2 2/summer/13/266/-1/0/false/false/false" #!String
+
  "301": "1 1 2 3 3/fall/38/398/3/0/false/true/false",
486: "2 3 2 3 3/summer/14/268/-1/0/false/false/false" #!String
+
  "299": "1 2 2 2/fall/39/300/-1/1/false/false/false",
487: "2 3 3 3 3/summer fall/15/270/4/0/true 1 2 5 0/false/false" #!String
+
  "488": "1 1 1 1 1/fall/16/272/5/0/true 1 1 0 .002/false/false",
488: "1 1 1 1 1/fall/16/272/5/0/true 1 2 10 .002/false/false" #!String
+
  "489": "2 2 1 2 1/fall/17/274/-1/0/false/false/false",
489: "2 2 1 2 1/fall/17/274/-1/0/false/false/false" #!String
+
  "490": "1 2 3 4 3/fall/18/276/-1/0/false/false/false",
490: "1 2 3 4 3/fall/18/276/-1/0/false/false/false" #!String
+
  "491": "1 1 1 1/fall/19/278/-1/0/false/false/false",
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",
492: "1 3 3 3/fall/20/280/-1/0/false/false/false" #!String
+
  "493": "1 2 1 1 2/fall/21/282/5/0/true 2 2 0 .1/false/false",
493: "1 2 1 1 2/fall/21/282/5/0/true 2 6 5 .1/false/false" #!String
+
  "494": "1 1 2 2/fall/22/284/-1/0/false/false/false",
494: "1 1 2 2/fall/22/284/-1/0/false/false/false" #!String
+
  "499": "2 7 7 7 5/spring summer fall/24/454/7/0/false/false/false",
495: "3 4/spring/23/16/-1/0/false/false/false" #!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",
496: "3 4/summer/23/396/-1/0/false/false/false" #!String
+
  "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",
497: "3 4/fall/23/404/-1/0/false/false/false" #!String
+
  "453": "1 2 2 2/summer/28/376/-1/0/false/false/true 255 0 0 254 254 254 255 170 0",
498: "3 4/winter/23/412/-1/0/false/false/false" #!String
+
  "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",
499: "2 7 7 7 5/spring summer fall/24/454/7/0/false/false/false" #!String
+
  "431": "1 2 3 2/summer fall/30/421/-1/0/false/false/false",
745: "1 1 2 2 2/spring/36/400/4/0/true 1 1 5 .02/false/false" #!String
+
  "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",
</source>
+
  "347": "2 4 6 6 6/fall/32/417/-1/0/false/false/false",
 +
  "495": "3 4/spring/23/16/-1/0/false/false/false",
 +
  "496": "3 4/summer/23/396/-1/0/false/false/false",
 +
  "497": "3 4/fall/23/404/-1/0/false/false/false",
 +
  "498": "3 4/winter/23/412/-1/0/false/false/false",
 +
  "885": "1 2 2 2/spring summer fall winter/44/771/-1/1/true 4 7 0 .01/false/false",
 +
  "890": "1 1 1 1/spring summer fall winter/47/889/-1/0/false/false/false",
 +
}
 +
</syntaxhighlight>}}
  
 
==Format==
 
==Format==
 
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 58: Line 65:
 
|-
 
|-
 
| Key
 
| Key
| Seed Index <small>(from [[Modding:Object data|ObjectInformation.xnb]])</small>
+
| Seed Index <small>(from [[Modding:Items|ObjectInformation.xnb]])</small>
 
| 473 <small>''(Bean Starter)''</small>
 
| 473 <small>''(Bean Starter)''</small>
 
| 455 <small>''(Spangle Seeds)''</small>
 
| 455 <small>''(Spangle Seeds)''</small>
Line 73: Line 80:
 
|-
 
|-
 
| 2
 
| 2
| Row in Sprite Sheet <small>(<tt>Content\TileSheets\Crops.xnb</tt>)</small>
+
| Index in Sprite Sheet <small>(<samp>Content\TileSheets\Crops.xnb</samp>)</small>
 
| 1
 
| 1
 
| 29
 
| 29
 
|-
 
|-
 
| 3
 
| 3
| Index of Harvest <small>(from [[Modding:Object data|ObjectInformation.xnb]])</small>
+
| Index of Harvest <small>(from [[Modding:Items|ObjectInformation.xnb]])</small>
 
| 188 <small>''(Green Bean)''</small>
 
| 188 <small>''(Green Bean)''</small>
 
| 593 <small>''(Summer Spangle)''</small>
 
| 593 <small>''(Summer Spangle)''</small>
Line 108: Line 115:
 
|}
 
|}
  
===Regrow after Harvest===
+
===Days in each stage of growth===
Either -1 for no regrowth, or number of days until regrowth.
+
The number of days in each visual step of growth. The final stage will be harvestable after the specified number of days.
  
===Harvest Method===
+
Note that speedgrow/agricultralist can only remove up to 3 days per stage of growth, so if your growth stages are very long the fertilizers may appear to work weirdly.
 +
 
 +
===Regrow after harvest===
 +
Either -1 for no regrowth, or the number of days until the crop can be harvested again.
 +
 
 +
===Harvest method===
 
1 for Scythe, 0 for all others
 
1 for Scythe, 0 for all others
  
===Chance for Extra Harvest===
+
===Chance for extra harvest===
 
If this value is true, then the numbers that follow are parsed as:
 
If this value is true, then the numbers that follow are parsed as:
 
#minHarvest
 
#minHarvest
Line 121: Line 133:
 
#chanceForExtraCrops
 
#chanceForExtraCrops
  
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:
+
The game determines the number of crops gained at a single harvest using the following code from <samp>Crops.cs::harvest()</samp>, where <samp>num</samp> is the number of crops gained:
  
<source lang="C#">
+
<syntaxhighlight lang="C#">
 
if (this.minHarvest > 1 || this.maxHarvest > 1)
 
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));
+
     num = random.Next(this.minHarvest, Math.Max(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))
+
if (this.chanceForExtraCrops > 0.0)
            num++;
+
    while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops))
 +
        num++;
  
 
if (random.NextDouble() < (double)Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
 
if (random.NextDouble() < (double)Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
 
     num *= 2;
 
     num *= 2;
</source>
+
</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.
+
The value in <samp>chanceForExtraCrops</samp> 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.  
#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:  Coffee Bean (433), Blueberry Seeds (481), and Cranberry Seeds (493).
 
  
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.
+
The chance for doubling the determined yield depends on Daily Luck: With a minimal value of -0.1 and a maximal value of +0.125 (accounting for the [[Special Charm]]), the chance ranges from 0.001<span style="text-decoration: overline">6</span>% (1 out of 60,000) to 0.02041<span style="text-decoration: overline">6</span>% (49 out of 240,000; or roughly 1 out of 4,898).
  
===Raised Seeds===
+
===Raised seeds===
 
True for trellis crops (Grapes, Hops, Green Beans), false for all others.
 
True for trellis crops (Grapes, Hops, Green Beans), false for all others.
  
===Tint Color===
+
===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:
 
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(0, 208, 255)
Line 154: Line 164:
  
 
[[Category:Modding]]
 
[[Category:Modding]]
 +
 +
[[fr:Modding:Données des récoltes]]
 +
[[ru:Модификации:Культуры]]
 +
[[zh:模组:农作物数据]]

Latest revision as of 20:47, 22 January 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 Content\Data\Crops.xnb, which can be unpacked for editing. Here's the raw data as of 1.5.1 for reference:

Data 
{
  "472": "1 1 1 1/spring/0/24/-1/0/false/false/false",
  "473": "1 1 1 3 4/spring/1/188/3/0/false/true/false",
  "474": "1 2 4 4 1/spring/2/190/-1/0/false/false/false",
  "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",
  "273": "1 2 2 3/spring/34/271/-1/1/true 1 1 10 .1/false/false",
  "831": "1 2 3 4/summer/42/830/-1/0/false/false/false",
  "477": "1 2 2 1/spring/5/250/-1/1/false/false/false",
  "478": "2 2 2 3 4/spring/6/252/-1/0/false/false/false",
  "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",
  "480": "2 2 2 2 3/summer/8/256/4/0/true 1 1 0 .05/false/false",
  "481": "1 3 3 4 2/summer/9/258/4/0/true 3 3 0 .02/false/false",
  "482": "1 1 1 1 1/summer/10/260/3/0/true 1 1 0 .03/false/false",
  "483": "1 1 1 1/summer fall/11/262/-1/1/false/false/false",
  "484": "2 1 2 1/summer/12/264/-1/0/false/false/false",
  "485": "2 1 2 2 2/summer/13/266/-1/0/false/false/false",
  "486": "2 3 2 3 3/summer/14/268/-1/0/false/false/false",
  "833": "1 3 3 4 3/summer/43/832/7/0/false/false/false",
  "433": "1 2 2 3 2/spring summer/40/433/2/0/true 4 4 0 .02/false/false",
  "802": "2 2 2 3 3/spring summer fall winter/41/90/3/0/false/false/false",
  "487": "2 3 3 3 3/summer fall/15/270/4/0/false/false/false",
  "302": "1 1 2 3 4/summer/37/304/1/0/false/true/false",
  "301": "1 1 2 3 3/fall/38/398/3/0/false/true/false",
  "299": "1 2 2 2/fall/39/300/-1/1/false/false/false",
  "488": "1 1 1 1 1/fall/16/272/5/0/true 1 1 0 .002/false/false",
  "489": "2 2 1 2 1/fall/17/274/-1/0/false/false/false",
  "490": "1 2 3 4 3/fall/18/276/-1/0/false/false/false",
  "491": "1 1 1 1/fall/19/278/-1/0/false/false/false",
  "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",
  "494": "1 1 2 2/fall/22/284/-1/0/false/false/false",
  "499": "2 7 7 7 5/spring summer fall/24/454/7/0/false/false/false",
  "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",
  "453": "1 2 2 2/summer/28/376/-1/0/false/false/true 255 0 0 254 254 254 255 170 0",
  "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",
  "431": "1 2 3 2/summer fall/30/421/-1/0/false/false/false",
  "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",
  "347": "2 4 6 6 6/fall/32/417/-1/0/false/false/false",
  "495": "3 4/spring/23/16/-1/0/false/false/false",
  "496": "3 4/summer/23/396/-1/0/false/false/false",
  "497": "3 4/fall/23/404/-1/0/false/false/false",
  "498": "3 4/winter/23/412/-1/0/false/false/false",
  "885": "1 2 2 2/spring summer fall winter/44/771/-1/1/true 4 7 0 .01/false/false",
  "890": "1 1 1 1/spring summer fall winter/47/889/-1/0/false/false/false",
}

Format

Index Field Example Value
Key Seed Index (from ObjectInformation.xnb) 473 (Bean Starter) 455 (Spangle Seeds)
0 Days in each stage of growth 1 1 1 3 4 1 2 3 2
1 Growth Season(s) spring summer
2 Index in Sprite Sheet (Content\TileSheets\Crops.xnb) 1 29
3 Index of Harvest (from ObjectInformation.xnb) 188 (Green Bean) 593 (Summer Spangle)
4 Regrow after Harvest 3 -1
5 Harvest Method 0 0
6 Chance for Extra Harvest true 1 2 6 0 false
7 Raised Seeds true false
8 Tint Color 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

The number of days in each visual step of growth. The final stage will be harvestable after the specified number of days.

Note that speedgrow/agricultralist can only remove up to 3 days per stage of growth, so if your growth stages are very long the fertilizers may appear to work weirdly.

Regrow after harvest

Either -1 for no regrowth, or the number of days until the crop can be harvested again.

Harvest method

1 for Scythe, 0 for all others

Chance for extra harvest

If this value is true, then the numbers that follow are parsed as:

  1. minHarvest
  2. maxHarvest
  3. maxHarvestIncreasePerFarmingLevel
  4. chanceForExtraCrops

The game determines the number of crops gained at a single harvest using the following code from Crops.cs::harvest(), where num is the number of crops gained:

if (this.minHarvest > 1 || this.maxHarvest > 1)
    num = random.Next(this.minHarvest, Math.Max(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;

The value in chanceForExtraCrops may add additional crops to a harvest, calculated independently of the other 3 variables. For example, each harvest of a Potato Seed (475) has ≈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 ≈2% chance of yielding an extra Blueberry, in addition to the 3 Blueberries given as standard harvest.

The chance for doubling the determined yield depends on Daily Luck: With a minimal value of -0.1 and a maximal value of +0.125 (accounting for the Special Charm), the chance ranges from 0.0016% (1 out of 60,000) to 0.020416% (49 out of 240,000; or roughly 1 out of 4,898).

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)