Modding:Crop data

From Stardew Valley Wiki
Revision as of 23:54, 30 November 2019 by Metalax (talk | contribs) (Update raw data to 1.4)
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 Content\Data\Crops.xnb, which can be unpacked for editing. Here's the raw data as of 1.4 for reference:

Data 
{
  "273": "1 2 2 3/spring/34/271/-1/1/true 1 1 10 .1/false/false",
  "299": "1 2 2 2/fall/39/300/-1/1/false/false/false",
  "301": "1 1 2 3 3/fall/38/398/3/0/false/true/false",
  "302": "1 1 2 3 4/summer/37/304/1/0/false/true/false",
  "347": "2 4 6 6 6/fall/32/417/-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",
  "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",
  "431": "1 2 3 2/summer fall/30/421/-1/0/false/false/false",
  "433": "1 2 2 3 2/spring summer/40/433/2/0/true 4 4 0 .02/false/false",
  "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",
  "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",
  "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",
  "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",
  "487": "2 3 3 3 3/summer fall/15/270/4/0/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",
  "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",
  "499": "2 7 7 7 5/spring summer fall/24/454/7/0/false/false/false",
  "745": "1 1 2 2 2/spring/36/400/4/0/true 1 1 0 .02/false/false",
  "802": "2 2 2 3 3/spring summer fall winter/41/90/3/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.

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.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;

The result (i.e., num) of random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)) is always the minHarvest, for 2 reasons.

  1. Taking the Math.Min of (minHarvest + 1) and (this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel) always results in (minHarvest + 1)
  2. random.Next uses an inclusive lower bound and an exclusive upper bound, so it is effectively calculating a random number between minHarvest and minHarvest

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 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.

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)