Modding:Items

From Stardew Valley Wiki
Jump to navigation Jump to search

Index

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

Introduction

Overview

As of Stardew Valley 1.6, there are a few important features of Items in the game.

  1. Each item as a string ID (ItemId) and a globally-unique string ID (QualifiedItemId). The QualifiedItemId is auto-generated by prefixing the ItemId with the item type identifier.

    For legacy reasons, the ItemId for vanilla items may not be globally unique. For example, Pufferfish (object 128) and Mushroom Box (bigcraftable 128) both have ItemId: 128. They can be distinguished by their QualifiedItemId, which are (O)128 and (BC)128 respectively.

  2. Each item type has an item data definition in the game code which tells the game how to handle it. C# mods can add or edit definitions. Each definition has a unique prefix which is used in the qualified item IDs. The vanilla types are bigcraftables ((BC)), boots ((B)), farmhouse flooring ((FL)), furniture ((F)), hats ((H)), objects ((O)), pants ((P)), shirts ((S)), tools ((T)), wallpaper ((WP)), and weapons ((W)).
  3. Custom items can now provide their own item texture, specified in a new field in the item data assets (see below). The item's ParentSheetIndex field is the index within that texture.

In other words, the four important fields for items are:

name type description
ItemId string A unique string ID for this item which should be globally unique (but may not be for existing vanilla items for backwards compatibility). For example, 128 (vanilla item) or Example.ModId_Watermelon (custom item).
QualifiedItemId string A globally unique item key, like (O)128 for a vanilla item or (O)Example.ModId_Watermelon for a custom one. This is auto-generated from the TypeDefinitionId and ItemId fields.
ParentSheetIndex int The item's sprite index within its spritesheet.
TypeDefinitionId string The ID for the data definition which defines the item, like (O) for an object. You can use ItemRegistry.type_* constants with this field:
if (item.TypeDefinitionId == ItemRegistry.type_object)
   ...

Item references

Item references throughout the game code now use the ItemId instead of the ParentSheetIndex. Since the ItemId is identical to the index for existing vanilla items, most data assets are unaffected by this change. For example, here's from Data/NPCGiftTastes with one custom item:

"Universal_Like": "-2 -7 -26 -75 -80 72 395 613 634 635 636 637 638 724 459 Example.ModID_watermelon"

Unless otherwise noted, unqualified item IDs will produce objects. Some assets let you override that by specifying a QualifiedItemId value instead. For example, you can add (O)128 to the gift taste list to explicitly add for an object. Here's a partial list of data assets and their supported item ID formats:

data asset item ID format
Data/CraftingRecipes
Data/CookingRecipes
  • Ingredients: both supported.
  • Output: set field 2 to the unqualified item ID, and field 3 to one of true (bigcraftable) or false (object).
Data/FruitTrees
  • Fruit: both supported.
  • Sapling: unqualified only.
Data/NPCGiftTastes Both supported, but only (O) items can be gifted.

Item types

These are the item types for which custom items can added/edited:

item type type identifier data asset
Big craftables (BC) Data/BigCraftables
Each item can set a custom texture name in the Texture field, and sprite index in the SpriteIndex field. The default texture is TileSheets/Craftables.
Boots (B) Data/Boots
Each item can set a custom texture name in fields 9 (item) and 7 (shoe color), and sprite index in fields 8 (item) and 5 (shoe color). The default textures are Maps/springobjects (item) and Characters/Farmer/shoeColors (shoe color).
Crops not technically an item type Data/Crops
Each crop can set a custom texture name and sprite index. The default texture is TileSheets/crops.
Fish (in fish tanks) not technically an item type Data/AquariumFish
Each fish can set a custom aquarium texture name in field 6, and sprite index in field 0. The default texture is LooseSprites/AquariumFish.
Furniture (F) Data/Furniture
Each item can set a custom texture name in field 9, and sprite index in field 8. The default texture is TileSheets/furniture.
Fruit Trees not technically an item type Data/FruitTrees
Each fruit tree can set a custom texture name and sprite index. The default texture is TileSheets/fruitTrees.
Hats (H) Data/Hats
Each item can set a custom texture name in field 7, and sprite index in field 6. The default texture is Characters/Farmer/hats.
Objects (O) Data/Objects
Each item can set a custom texture name in the Texture field, and sprite index in the SpriteIndex field. The default texture is Maps/springobjects.
Pants (P) Data/pantsData
Each item can set a custom texture name in the Texture field, and sprite index in the SpriteIndex field. The default texture is Characters/Farmer/pants.
Shirts (S) Data/shirtData
Each item can set a custom texture name in the Texture field, and sprite index in the SpriteIndex field. The default texture is Characters/Farmer/shirts.

Shirt textures must be exactly 256 pixels wide, divided into two halves: the left half for the shirt sprites, and the right half for any dye masks. The remaining space can be left blank if needed.

      sprites       dye masks
   /-----------\  /-----------\
┌────────────────────────────────┐
│ ┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐ │
│ │ 0 ││ 1 ││ 2 ││ a ││ b ││ c │ │
│ └───┘└───┘└───┘└───┘└───┘└───┘ │
│ ┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐ │
│ │ 3 ││ 4 ││ 5 ││ d ││ e ││ f │ │
│ └───┘└───┘└───┘└───┘└───┘└───┘ │
└────────────────────────────────┘
Tools (T) Data/Tools
Each item can set a custom texture name in the Texture field, and sprite index in the SpriteIndex field. The vanilla tools use the TileSheets/Tools texture.
Wallpaper & flooring (WP) and (FL) Data/AdditionalWallpaperFlooring
See format docs.
Weapons (W) Data/Weapons

When resolving an unqualified item ID like 128, the game will get the first item type for which it exists in this order: object, big craftable, furniture, weapon, boots, hat, pants, shirt, tool, wallpaper, and floorpaper.

For each item type, the game has two files in its Content folder (which can be unpacked for editing):

  • a data asset for the text data for its items (names, descriptions, prices, etc);
  • and a spritesheet for the in-game item icons.

Each item has a ParentSheetIndex field which is its position in the item type's spritesheet, starting at 0 in the top-left and incrementing by one as you move across and then down. For example, hat #0 is the first sprite in Characters/Farmer/hats. The ParentSheetIndex is also used to identify the item itself; since spritesheet indexes aren't unique (e.g., there's both a hat #10 and object #10), code needs to check the type too like item is Weapon weapon && weapon.ParentSheetIndex == 4.

Get a list of items

With SMAPI installed, you can run the list_items console command in-game to view/search items and their IDs.

Define a custom item

You can define custom items for most vanilla item types using only Content Patcher or SMAPI's content API.

For example, this content pack adds a new Pufferchick item with a custom image, custom gift tastes, and a custom crop that produces it. Note that item references in other data assets like Data/Crops and Data/NPCGiftTastes use the item ID.

{
    "Format": "2.0.0",
    "Changes": [
        // add item
        {
            "Action": "EditData",
            "Target": "Data/Objects",
            "Entries": {
                "{{ModId}}_Pufferchick": {
                    "Name": "{{ModId}}_Pufferchick", // best practice to match the ID, since it's sometimes used as an alternate ID (e.g. in Data/CraftingRecipes)
                    "Displayname": "Pufferchick",
                    "Description": "An example object.",
                    "Type": "Seeds",
                    "Category": -74,
                    "Price": 1200,

                    "Texture": "Mods/{{ModId}}/Objects",
                    "SpriteIndex": 0
                }
            }
        },

        // add gift tastes
        {
            "Action": "EditData",
            "Target": "Data/NPCGiftTastes",
            "TextOperations": [
                {
                    "Operation": "Append",
                    "Target": ["Entries", "Universal_Love"],
                    "Value": "{{ModId}}_Pufferchick",
                    "Delimiter": " " // if there are already values, add a space between them and the new one
                }
            ]
        },

        // add crop (Pufferchick is both seed and produce, like coffee beans)
        {
            "Action": "EditData",
            "Target": "Data/Crops",
            "Entries": {
                "{{ModId}}_Pufferchick": {
                    "Seasons": [ "spring", "summer", "fall" ],
                    "DaysInPhase": [ 1, 1, 1, 1, 1 ],
                    "HarvestItemId": "{{ModId}}_Pufferchick",

                    "Texture": "Mods/{{ModId}}/Crops",
                    "SpriteIndex": 0
                }
            }
        },

        // add item + crop images
        {
            "Action": "Load",
            "Target": "Mods/{{ModId}}/Crops, Mods/{{ModId}}/Objects",
            "FromFile": "assets/{{TargetWithoutPath}}.png" // assets/Crops.png, assets/Objects.png
        }
    ]
}

Most item data assets work just like Data/Objects. See also specific info for custom fruit trees, custom tools, and melee weapons.

Error items

Prior to 1.6, in-game items with no underlying data (e.g. because you removed the mod which adds them) would previously cause issues like invisible items, errors, and crashes. This was partly mitigated by the bundled Error Handler mod.

Stardew Valley 1.6 added comprehensive handling for such items. They'll be shown with a 🛇 sprite in inventory UIs and in-game, the name Error Item, and a description which indicates the missing item ID for troubleshooting.

For C# mods

Compare items
Since Item.QualifiedItemId is globally unique, it can be used to simplify comparing items. For example:
old code new code
item.ParentSheetIndex == 128 item.QualifiedItemId == "(O)128"
IsNormalObjectAtParentSheetIndex(item, 128) item.QualifiedItemId == "(O)128"
!item.bigCraftable && item.ParentSheetIndex == 128 item.QualifiedItemId == "(O)128"
item is Boots && item.ParentSheetIndex == 505 item.QualifiedItemId == "(B)505"

You can also use ItemRegistry.QualifyItemId to convert any item ID into a qualified one (if it's valid), and ItemRegistry.HasItemId to check if an item has a qualified or unqualified item ID.

Note that flavored item don't have their own ID. For example, Blueberry Wine and Wine are both (O)348. This affects flavored jellies, juices, pickles, and wines. In those cases you should still compare their separate fields like preservedParentSheetIndex (which actually contains the preserved item's ItemId, not its ParentSheetIndex).

Construct items
When constructing items, specify the item's ItemId (not QualifiedItemId). For example:
new Object("128", 1);                      // vanilla item
new Object("Example.ModId_Watermelon", 1); // custom item

You can use a utility method to construct items from their QualifiedItemId:

Item item = ItemRegistry.Create("(B)505"); // Rubber Boots
Define custom item types
You can implement IItemDataDefinition for your own item type, and call ItemRegistry.AddTypeDefinition to register it. This provides all the logic needed by the game to handle the item type: where to get item data, how to draw them, etc. This is extremely specialized, and multiplayer compatibility is unknown. Most mods should add custom items within the existing types instead.
New Is* methods
1.6 added some StardewValley.Object methods to handle custom items in a generic way (and to let mods patch the logic):
method effect
object.IsBar() Whether the item is a copper bar, iron bar, gold bar, iridium bar, or radioactive bar.
object.IsBreakableStone() Whether the item is a stone debris item which can be broken by a pickaxe.
object.IsFence() Whether the item is a fence.
object.IsFruitTreeSapling() Whether the item is a fruit tree sapling. This checks the Data\fruitTrees keys, so it works with custom fruit trees too.
object.IsHeldOverHead() Whether the player is shown holding up the item when it's selected in their toolbar. Default true (except for furniture).
object.IsIncubator() Whether the item can incubate farm animal eggs when placed in a building.
object.IsTapper() Whether the item is a tapper or heavy tapper.
object.IsTeaSapling() Whether the item is a tea sapling.
object.IsTwig() Whethere the item is a twig debris item.
object.IsWeeds() Whether the item is a weed debris item.
Work with item metadata
1.6 added an ItemRegistry API for working with the new item system. Some of the provided methods are:
method effect
ItemRegistry.Create Create an item from its item ID (qualified or unqualified). If the ID doesn't match a real item, the optional allowNull parameter indicates whether to return null or an Error Item. For example:
Item item = ItemRegistry.Create("(B)505"); // Rubber Boots

You can also get a specific value type instead of Item if needed. This will throw a descriptive exception if the type isn't compatible (e.g. you try to convert furniture to boots).

Boots item = ItemRegistry.Create<Boots>("(B)505"); // Rubber Boots
ItemRegistry.Exists Get whether a qualified or unqualified item ID matches an existing item. For example:
bool pufferfishExist = ItemRegistry.Exists("(O)128");
ItemRegistry.IsQualifiedId Get whether the given item ID is qualified with the type prefix (like (O)128 instead of 128).
ItemRegistry.QualifyItemId Get the unique qualified item ID given an unqualified or qualified one. For example:
string qualifiedId = ItemRegistry.QualifyItemId("128"); // returns (O)128
ItemRegistry.GetMetadata This lets you get high-level info about an item:
// get info about Rubber Boots
ItemMetadata info = ItemRegistry.GetMetadata("(B)505");

// get item ID info
$"The item has unqualified ID {info.LocalId}, qualified ID {info.QualifiedId}, and is defined by the {info.TypeIdentifier} item data definition.";

// does the item exist in the data files?
bool exists = info.Exists();

And get common parsed item data:

// get parsed info
ParsedItemData data = info.GetParsedData();
$"The internal name is {data.InternalName}, translated name {data.DisplayName}, description {data.Description}, etc.";

// draw an item sprite
Texture2D texture = data.GetTexture();
Rectangle sourceRect = data.GetSourceRect();
spriteBatch.Draw(texture, Vector2.Zero, sourceRect, Color.White);

And create an item:

Item item = metadata.CreateItem();

And get the type definition (note that this is very specialized, and you should usually use ItemRegistry instead to benefit from its caching and optimizations):

IItemDataDefinition typeDefinition = info.GetTypeDefinition();
ItemRegistry.ResolveMetadata Equivalent to ItemRegistry.GetMetadata, except that it'll return null if the item doesn't exist.
ItemRegistry.GetData Get the parsed data about an item, or null if the item doesn't exist. This is a shortcut for ItemRegistry.ResolveMetadata(id)?.GetParsedData(); see the previous method for info on the parsed data.
ItemRegistry.GetDataOrErrorItem Equivalent to ItemRegistry.GetData, except that it'll return info for an Error Item if the item doesn't exist (e.g. for drawing in inventory).
ItemRegistry.GetErrorItemName Get a translated Error Item label.

Common data

Quality

Each item has a quality level which (depending on the item type) may affect its price, health boost, etc. The valid qualities are:

quality value constant
normal 0 Object.lowQuality
silver 1 Object.medQuality
gold 2 Object.highQuality
iridium 4 Object.bestQuality

Categories

Each item also has a category (represented by a negative integer). In code, you can get an item's category value from item.Category, and its translated name from item.getCategoryName(). Here are the valid categories:

value internal constant context tag English translation Properties
-2 Object.GemCategory category_gem Mineral Affected by Gemologist profession
-4 Object.FishCategory category_fish Fish Affected by Fisher and Angler professions
-5 Object.EggCategory category_egg Animal Product Affected by Rancher profession, can be used in a slingshot
-6 Object.MilkCategory category_milk Animal Product Affected by Rancher profession
-7 Object.CookingCategory category_cooking Cooking
-8 Object.CraftingCategory category_crafting Crafting Is Placeable
-9 Object.BigCraftableCategory category_big_craftable Is Placeable
-12 Object.mineralsCategory category_minerals Mineral Affected by Gemologist profession
-14 Object.meatCategory category_meat Animal Product
-15 Object.metalResources category_metal_resources Resource
-16 Object.buildingResources category_building_resources Resource
-17 Object.sellAtPierres category_sell_at_pierres
-18 Object.sellAtPierresAndMarnies category_sell_at_pierres_and_marnies Animal Product Affected by Rancher profession
-19 Object.fertilizerCategory category_fertilizer Fertilizer Is Placeable, is always passable
-20 Object.junkCategory category_junk Trash
-21 Object.baitCategory category_bait Bait Can be attached to a fishing rod
-22 Object.tackleCategory category_tackle Fishing Tackle Can be attached to a fishing rod, cannot stack
-23 sellAtFishShopCategory category_sell_at_fish_shop
-24 Object.furnitureCategory category_furniture Decor
-25 Object.ingredientsCategory category_ingredients Cooking
-26 Object.artisanGoodsCategory category_artisan_goods Artisan Goods Affected by Artisan profession
-27 Object.syrupCategory category_syrup Artisan Goods Affected by Tapper profession
-28 Object.monsterLootCategory category_monster_loot Monster Loot
-29 Object.equipmentCategory category_equipment
-74 Object.SeedsCategory category_seeds Seed Is Placeable, is always passable
-75 Object.VegetableCategory category_vegetable Vegetable Affected by Tiller profession, can be used in a slingshot
-79 Object.FruitsCategory category_fruits Fruit Affected by Tiller profession (if not foraged), can be used in a slingshot
-80 Object.flowersCategory category_flowers Flower Affected by Tiller profession
-81 Object.GreensCategory category_greens Forage
-95 Object.hatCategory category_hat
-96 Object.ringCategory category_ring
-98 Object.weaponCategory category_weapon
-99 Object.toolCategory category_tool
Console commands 
With the Console Code mod installed, you can run this command in the SMAPI console to see a list of objects by category:
cs return string.Join(`\n`, Game1.objectData.Keys.Select(key => new StardewValley.Object(key, 1)).GroupBy(item => item.Category, item => item.Name).OrderByDescending(p => p.Key).Select(p => $`{p.Key}: {string.Join(`, `, p.OrderBy(name => name))}`));

Context tags

A context tag is an arbitrary data label attached to items. These can produce various effects in-game, or may be informational only.

The game generates some tags based on the game data (like the item quality), and others are defined in the Data/ObjectContextTags data asset (which consists of a string→string dictionary, where the key is the item's internal name or the alternative ID matching the id_<type>_<identifier> tag, and the value is a comma-delimited list of tags to add).

Here's an incomplete list of context tags added or used in the base game. Mods can add custom context tags, which aren't listed here.

Added automatically for all items:
context tag effect
category_<category> Added automatically based on the item category. See the 'context tag' column in the item category list for possible values.
fish_<metadata> Added automatically for a fish item based on its metadata in Data/Fish.

For crab pot fish (i.e. those with type trap):

context tag notes
fish_trap_location_<water type> Based on field 2 ('darting randomness'). For example, fish_trap_location_ocean.

For fishing rod fish (i.e. those whose type is not trap):

context tag notes
fish_difficulty_<difficulty> Based on field 1 ('chance to dart'), where <difficulty> is one of easy (0–33), medium (34–66), hard (67–100), or extremely_hard (101+). For example, fish_difficulty_hard.
fish_motion_<motion> Based on field 4 ('location'). For example, fish_motion_floater.
fish_favor_weather_<weather> Based on field 7 ('weather'). For example, fish_favor_weather_sunny.
id_<type>_<identifier> Added automatically as an alternative ID. The <type> is one of B (boots), BBL (big craftable recipe), BL (object recipe), BO (big craftable), C (clothing), F (furniture), H (hat), O (object), R (ring), W (melee weapon), else blank. The <identifier> is the item's parent sheet index. For example, pufferfish has value id_o_128 (object #128).
item_<name> Added automatically based on the item name. The name is trimmed, lowercase, with spaces replaced with underscores, and with single quotes removed. For example, '1000 Years From Now' has context tag item_1000_years_from_now.
Added automatically for object-type items:
context tag effect
jelly_item
juice_item
pickle_item
wine_item
For items produced by the keg or preserves jar, the preserved item type.
preserve_sheet_index_<id> For items produced by the keg or preserves jar, the parent sheet index for the original item that was produced. For example, blueberry wine has preserve_sheet_index_258, where 258 is the blueberry item's index.
quality_none
quality_silver
quality_gold
quality_iridium
Added automatically based on the item quality.
quality_qi Added automatically for items cooked while the Qi's Cuisine special order is active.
Context tags from Data/ObjectContextTags:
context tag effect
color_* The color produced by this item when the player dyes clothing at Emily's house. The context tag only affects which of the six color dye pots it can be placed in; for example, color_red and color_dark_red are both placed in the red pot, but they don't produce different colors.
dye pot context tags
red color_red, color_salmon, color_dark_red, color_pink
orange color_orange, color_dark_orange, color_dark_brown, color_brown, color_copper
yellow color_yellow, color_dark_yellow, color_gold, color_sand
green color_green, color_dark_green, color_lime, color_yellow_green, color_jade
blue color_blue, color_dark_blue, color_dark_cyan, color_light_cyan, color_cyan, color_aquamarine
purple color_purple, color_dark_purple, color_dark_pink, color_pale_violet_red, color_poppyseed, color_iridium

Some game data also references context tags in a generic way. For example, you can add custom tags for an item to Data/ObjectContextTags, then reference them in the fish pond data. Specifically:

game data effects
fish ponds In Data/FishPondData, used to match fish that can be placed in the pond (see RequiredTags in the fish pond data).
special orders In Data/SpecialOrders, used to match items that meet the quest objectives (see AcceptedContextTags in the special order data).
tailoring In Data/TailoringRecipes, used to match items that are needed for a recipe.
gift tastes In Data/NPCGiftTastes, used to set character likes and dislike for every item using the context tag.


The debug listtags console command lists all the tags of the item being held.

raw tag dump 
Here's a list of context tags extracted from Data/ObjectContextTags that aren't listed above yet: alcohol_item, algae_item, ancient_item, beach_item, bomb_item, bone_item, book_item, ceramic_item, chicken_item, color_black, color_dark_gray, color_gray, color_iron, color_prismatic, color_white, cooking_item, cow_milk_item, cowboy_item, crop_year_2, dinosaur_item, doll_item, drink_item, dwarvish_item, dye_medium, dye_strong, egg_item, elvish_item, fertilizer_item, fish_bug_lair, fish_carnivorous, fish_crab_pot, fish_desert, fish_freshwater, fish_lake, fish_legendary, fish_mines, fish_night_market, fish_nonfish, fish_ocean, fish_pond, fish_river, fish_secret_pond, fish_semi_rare, fish_sewers, fish_swamp, fish_talk_demanding, fish_talk_rude, fish_talk_stiff, fish_upright, flower_item, food_bakery, food_breakfast, food_cake, food_party, food_pasta, food_salad, food_sauce, food_seafood, food_soup, food_spicy, food_sushi, food_sweet, forage_item, forage_item_beach, forage_item_cave, forage_item_desert, forage_item_mines, forage_item_secret, fossil_item, fruit_item, fruit_tree_item, furnace_item, ginger_item, goat_milk_item, golden_relic_item, honey_item, hunting_item, instrument_item, jelly_item, juice_item, large_egg_item, large_milk_item, light_source, machine_item, marine_item, mayo_item, medicine_item, milk_item, noble_item, ore_item, pickle_item, potion_item, prehistoric_item, quality_fertilizer_item, scroll_item, season_all, season_fall, season_spring, season_summer, season_winter, slime_egg_item, slime_item, statue_item, strange_doll_1, strange_doll_2, syrup_item, totem_item, toy_item, trash_item, tree_seed_item, wood_item.

Objects

Objects are the default type for items in inventories or placed in the world.

They have their data in Data/Objects (Data/ObjectInformation prior to 1.6), their icon sprites in Maps/springobjects, and their code in StardewValley.Object. See a table of sprites and their corresponding indexes.

Data format

The object data in Data/Objects consists of a string → model lookup, where...

  • The key is the unqualified item ID.
  • The value is a model with the fields listed below.

Basic info

field purpose
Name The internal item name.
DisplayName
Description
A tokenizable string for the item's in-game display name and description.
Type The item's general type, like Arch (artifact) or Minerals. The vanilla types are: Litter, Basic, Minerals, Quest, asdf, Crafting, Arch, fish, Cooking, Seeds, Ring, interactive
Category The item category.
Price (Optional) The price when sold by the player. This is not the price when bought from a shop. Default 0.

Appearance

field purpose
Texture The asset name for the texture containing the item's sprite. Defaults to Maps/springobjects.
SpriteIndex The sprite's index within the Texture, where 0 is the top-left sprite.

Edibility

field purpose
Edibility (Optional) A numeric value that determines how much energy (edibility × 2.5) and health (edibility × 1.125) is restored when this item is eaten. An item with an edibility of -300 can't be eaten, values from -299 to -1 reduce health and energy, and zero can be eaten but doesn't change health/energy. Default -300.
IsDrink (Optional) Whether to drink the item instead of eating it. Default false.
Buffs (Optional) The buffs to apply to the player when this item is eaten, if any. Default none.

This consists of a list of models with these fields:

field purpose
Id The unique string ID for this entry within the list.
Duration (Optional if BuffId is set) The buff duration measured in in-game minutes. This can be set to -2 for a buff that should last for the rest of the day.
BuffId (Optional) The unique ID of a buff from Data/Buffs to apply, or null to ignore Data/Buffs and set the ID to food or drink depending on the item's IsDrink field.

If a buff from Data/Buffs is applied and you also specify other fields, here's how the buff data is combined:

field result
Duration
IconTexture
SpriteIndex
GlowColor
If specified, the value in Data/Objects is used instead of the one in Data/Buffs. If omitted, defaults to the value from Data/Buffs.
CustomAttributes The values from both entries are combined (e.g. +1 speed in Data/Objects and +1 speed in Data/Buffs results in +2 speed).
IsDebuff The value in Data/Objects is used.
IsDebuff (Optional) Whether this buff counts as a debuff, so its duration should be halved when wearing a Sturdy Ring. Default false.
IconTexture (Optional) The asset name for the icon texture to load. This must contain one or more 16x16 icons in a grid of any size. If omitted, the game will draw a default icon based on the BuffId and CustomAttributes fields.
SpriteIndex (Optional) The buff's icon index within the IconTexture, where 0 is the top-left icon. Default 0.
GlowColor (Optional) The glow color to apply to the player. See color format. Default none.
CustomAttributes The custom buff attributes to apply, if any.

This consists of a model with any combination of these fields:

field purpose
FarmingLevel
FishingLevel
ForagingLevel
LuckLevel
MiningLevel
(Optional) An amount applied to the matching skill level while the buff is active. This can be negative for a debuff. Default 0.
Attack
Defense
MagneticRadius
MaxStamina
Speed
(Optional) An amount applied to the player's attack, defense, magnetic radius, maximum stamina, or speed while the buff is active. This can be negative for a debuff. Default 0.
CustomFields (Optional) The custom fields for this entry.

Geodes & artifact spots

field purpose
GeodeDrops
GeodeDropsDefaultItems
(Optional) The items that can be dropped when breaking open this item as a geode. Specifying either or both fields automatically enables geode behavior for this item.

You can specify one or both fields:

  • GeodeDrops can be set to the specific items to drop. Default none. This consists of a list of models with these fields:
    field purpose
    common fields See item spawn fields for the generic item fields supported by geode drops.

    If set to an item query which returns multiple items, one of them will be selected at random.

    Chance (Optional) The probability that the item will be dropped if the other fields match, as a decimal value between 0 (never) and 1 (always). Default 1.
    SetFlagOnPickup (Optional) The mail flag to set for the current player when this drop is picked up.
    Precedence (Optional) The order in which this entry should be checked, where lower values are checked first. This can be a negative value. Geode drops with the same precedence are checked in the order listed. Default 0.

    For consistency, vanilla drops mostly use these values:

    • -1000: special overrides like the Golden Helmet;
    • 0: normal items.
  • GeodeDropsDefaultItems chooses a predefined list of possible geode drops like clay, coal, copper, iridium, etc. Default false.

If both fields are specified, each geode will choose between them with an equal 50% chance. If GeodeDrops is specified but no entries match, the geode will use the GeodeDropsDefaultItems regardless of whether it's true.

ArtifactSpotChances (Optional) If this is an artifact (i.e. the Type field is Arch), the chance that it can be found by digging artifact spots in each location.

This consists of a string → model lookup, where:

  • the key is the internal location name;
  • the value is the probability the item will spawn if checked, as a decimal value between 0 (never) and 1 (always).

Context tags & exclusions

field purpose
ContextTags (Optional) The custom context tags to add for this item (in addition to the tags added automatically based on the other object data). This is formatted as a list; for example:
"ContextTags": [ "color_yellow", "fish_ocean", "fish_upright", "season_summer" ]
ExcludeFromRandomSale (Optional) Whether to exclude this item from shops when selecting random items to sell. Default false.
ExcludeFromFishingCollection
ExcludeFromShippingCollection
(Optional) Whether to exclude this item from the fishing/shipping collection and their respective effect on the perfection score. Default false, in which case the normal requirements apply (e.g. artifacts are always excluded from the shipping collection).

Advanced

field purpose
CustomFields (Optional) The custom fields for this entry.

Notes

  • Prior to 1.6, items that have a number in index 6 (the "Crafting" field) showed buggy information in-game (e.g., Bean Hotpot prior to version 1.4). Items that had a number in the "Attack" field displayed the Attack icon and a number, but no description. It's unclear how these buffs work (if at all).
  • Adding custom items with the Arch type is inadvisable as it often leads to Artifact Spots becoming broken and not giving any items.
  • Named buffs (like Oil of Garlic, Life Elixir, or Tipsy) are implemented in code and can't be set in the food buff fields.
  • The spritesheet and data have items that can't normally be found in the player inventory (like twigs and lumber), and some sprites have no corresponding item data. There are also multiple entries for weeds and stone corresponding to different sprites, but the player can only normally obtain one stone item (index 390) and no weeds items.

Big craftables

Big craftables are objects which can be placed in the world and are two tiles tall (instead of one like objects).

They have their data in Data/BigCraftables (Data/BigCraftablesInformation prior to 1.6), their in-game sprites in TileSheets/Craftables, and their code in StardewValley.Object (with the bigCraftable.Value = true flag).

Data format

This consists of a string → model lookup, where...

  • The key is the unqualified item ID.
  • The value is a model with the fields listed below.

Basic info

field purpose
Name The internal item name.
DisplayName
Description
A tokenizable string for the item's in-game display name and description.
Price (Optional) The price when sold by the player. This is not the price when bought from a shop. Default 0.

Behavior

field purpose
Fragility (Optional) How the item can be picked up. The possible values are 0 (pick up with any tool), 1 (destroyed if hit with an axe/hoe/pickaxe, or picked up with any other tool), or 2 (can't be removed once placed). Default 0.
CanBePlacedIndoors
CanBePlacedOutdoors
(Optional) Whether the item can be placed indoors or outdoors. Default true.
IsLamp (Optional) Whether this is a lamp and should produce light when dark. Default false.

Appearance

field purpose
Texture (Optional) The asset name for the texture containing the item's sprite. Defaults to TileSheets/Craftables.
SpriteIndex (Optional) The sprite's index within the Texture, where 0 is the top-left sprite.

Context tags

field purpose
ContextTags (Optional) The custom context tags to add for this item (in addition to the tags added automatically based on the other object data). This is formatted as a list; for example:
"ContextTags": [ "light_source", "torch_item" ]

Advanced

field purpose
CustomFields (Optional) The custom fields for this entry.

Notes

  • Many of the items in the data asset aren't implemented in-game. They may be completely absent from the game, or they may be unused as craftables and instead appear in object data or furniture data.

Boots

Boots are items that can be equipped in the player's footwear slot.

They have their data in Data/Boots, their in-game sprites in Maps/springobjects (item sprite) and Characters/Farmer/shoeColors (shoe color), and their code in StardewValley.Objects.Boots.

Data format

The boots data in Data/Boots consists of an integer→string dictionary with entries like this:

  "511": "Dark Boots/Made from thick black leather./250/4/2/7"

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name (and display name in English).
1 description The translated item description shown in-game.
2 price Unused. The actual price is calculated as (added defence × 100) + (added immunity × 100).
3 added defense A defense bonus applied to the player while equipped.
4 added immunity An immunity bonus applied to the player while equipped.
5 color index The index of the boot color in the Characters/Farmer/shoeColors spritesheet.
6 display name The translated item name shown in-game (for non-English assets only).

Clothing

Clothing consists of cosmetic items that can be equipped in the player's pants and shirt slots.

They have their data in Data/ClothingInformation, their in-game sprites in Characters/Farmer/pants & Characters/Farmer/shirts, and their code in StardewValley.Objects.Clothing.

Data format

The clothing data in Data/ClothingInformation consists of an integer→string dictionary with entries like this:

  "1282": "Tomato Shirt/Tomato Shirt/A shirt that answers the big question: 'Tomatoes are'... (but the rest is smudged)./282/-1/50/255 0 0/false/Shirt/Sleeveless"

For each entry in the data asset, the key is the item's ParentSheetIndex (offset by 1000 for shirts) and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name (and display name in English).
1 display name The translated item name shown in-game.
2 description The translated item description shown in-game.
3 male index The sprite index in the clothing spritesheet for male characters.
4 female index The sprite index in the clothing spritesheet for female characters, or -1 to use the male index.
5 price The price when purchased from shops.
6 default color The default color, specified in space-delimited RGB with each channel being an integer from 0 (no color) to 255 (full color). For example, 255 0 0 for full red.
7 dyeable Whether the clothing can be dyed (true or false).
8 Type The clothing type. One of Pants, Shirt, or Accessory (unimplemented).
9 extra data A comma-delimited list of tags attached to the item (unrelated to context tags). The values recognized by the game are Prismatic (adds a shifting rainbow effect) and Sleeveless (disables drawing the sleeve color over the player's arms).

Furniture

Furniture are decorative items which can be placed in the world, including chairs which the player can sit on.

They have their data in Data/Furniture, their in-game sprites in TileSheets/furniture, and their code in StardewValley.Objects.Furniture.

Data format

The furniture data in Data/Furniture consists of an integer→string dictionary with entries like this:

  "18": "Country Chair/chair/-1/-1/4/750"

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name (and display name in English).
1 type The furniture type. Possible values:
type meaning
0 chair
1 bench
2 couch
3 armchair
4 dresser
5 long table
6 painting
7 lamp
8 decor
9 other
10 bookcase
11 table
12 rug
13 window
14 fireplace
15 bed
16 torch
17 sconce
2 tilesheet size The furniture sprite size on the tilesheet, measured in tiles. This can be <width> <height> (e.g. 1 2), or -1 to use the default size for the type.
3 bounding box size The size of the hitbox when the furniture is placed in-game, measured in tiles. The bounding box will be anchored to the bottom-left corner and extend upwards and rightwards. This can be <width> <height> (e.g. 1 2), or -1 to use the default size for the type.
4 rotations The number of rotations possible (1, 2, or 4).
5 price The price when purchased from a shop.
6 placement restriction Where the furniture can be placed.
value meaning
-1 default (uses furniture type)
0 indoors-only
1 outdoors-only
2 indoors or outdoors
7 display name The translated furniture name (in non-English data assets only).

Hats

Hats are items that can be equipped in the player's hat slot.

They have their data in Data/Hats, their in-game sprites in Characters/Farmer/hats, and their code in StardewValley.Objects.Hat.

Data format

The hat data in Data/Hats consists of an integer→string dictionary with entries like this:

  "5": "Official Cap/Looks like it belonged to a postman or policeman. Either way, it's still very soft and smells okay./false/true"

Hats from the base game use the hat's ParentSheetIndex as its item ID. For each entry in the data asset, the key is the hat's item ID, and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name.
1 description The translated item description shown in-game.
2 show real hair Whether to show the player's hairstyle as-is when the hat is worn (true), or change the hairstyle to fit the hat (false).
3 skip hairstyle offset Whether to ignore the current style when positioning the hat (one of true or false). For example, the eye patch sets true since its position isn't affected by the hair, but the butterfly bow sets false to adjust its position on top of your hair.
4 tags A space-separated list of "tags". These are separate from context tags, and used to contain miscellaneous information. Currently, the only tag used by the game is Prismatic, which marks a hat as prismatic and causes it to cycle through colors.
5 display name The translated item name shown in-game.
6 sprite index The index in the hat spritesheet used to display this hat.
7 texture name The name of the game texture to use for the hat. If empty, the game will use the default hat sheet Characters/Farmer/hats

Hats have a hard-coded category of -95 (HatDataDefinition.cs::GetData)

Tools

Tools are items that can be swung or used by the player to perform some effect (e.g. dig dirt, chop trees, etc).

They have their data in Data/Tools, their in-game sprites in TileSheets/Tools, and their code in StardewValley.Tool and various subclasses like StardewValley.Tools.Axe.

Data format

You can create/edit tools by editing theData/Tools asset. This consists of a string → model lookup, where...

  • The key is the unqualified item ID.
  • The value is a model with the fields listed below.

Basic tool data

field purpose
ClassName The name of the C# class to construct within the StardewValley.Tools namespace. The class must be a subclass of StardewValley.Tool, and have a constructor with no arguments. For example, given a value of Axe, the game will create StardewValley.Tools.Axe instances.

The main values are:

  • main tools (Axe, FishingRod, Hoe, MeleeWeapon, MilkPail, Pan, Pickaxe, Shears, Wand, and WateringCan);
  • a special GenericTool type which applies the Data/Tools data and only has generic logic, so C# mods can patch in their own logic;
  • and two tools cut from the game which may not work correctly (Lantern and Raft).
Name The internal name to set for the tool item.
DisplayName
Description
A tokenizable string for the tool's in-game display name and description.
AttachmentSlots (Optional) The number of attachment slots to enable on the tool. Note that only FishingRod tools have the code to render and use attachment slots. Default -1, which keeps the default value set by the tool class.
SalePrice (Optional) The default price when the item is sold to the player in a shop. Defaults to -1, in which case you should set the price manually in shops.
CustomFields The custom fields for this entry.

Appearance

Note that drawing the tool correctly in the world (ie, while the player is trying to use it) will likely require custom code.

field purpose
Texture The asset name for the texture containing the tool's sprite.
SpriteIndex The tool's sprite index within the Texture, where 0 is the top row.
MenuSpriteIndex (Optional) The sprite index within the Texture for the item icon. Defaults to SpriteIndex.

Upgrades

field purpose
UpgradeLevel (Optional) The tool upgrade level. Default -1, which keeps the default value set by the tool class.
ApplyUpgradeLevelToDisplayName (Optional) Whether to adjust the DisplayName for the usual upgrade levels. For example, the display name for a level one Axe changes to 'Copper Axe'. Default false.

The display name format in English is:

upgrade level display name format
1 Copper <display name>
2 Steel <display name>
3 Gold <display name>
4 Iridium <display name>
ConventionalUpgradeFrom (Optional) If set, prepends an upgrade for the given tool ID to the UpgradeFrom field. This applies these rules (based on the UpgradeLevel field, not the upgrade level of the specified tool ID):
upgrade level price items needed
1 data-sort-value="2000">Gold.png2,000g Copper Bar.png Copper Bar (5)
2 data-sort-value="5000">Gold.png5,000g Iron Bar.png Iron Bar (5)
3 data-sort-value="10000">Gold.png10,000g Gold Bar.png Gold Bar (5)
4 data-sort-value="25000">Gold.png25,000g Iridium Bar.png Iridium Bar (5)

For example, Iridium Axe specifies this value:

"ConventionalUpgradeFrom": "(T)GoldAxe"
UpgradeFrom (Optional) The requirements to buy this tool from Clint's blacksmith tool upgrade shop. If you specify multiple entries, the first one which matches will be applied.

This consists of a list of models with these fields:

field purpose
Price (Optional) The gold price to buy the upgrade. Defaults to 0.
RequireToolId (Optional) If set, the qualified or unqualified item ID for the tool that must be in the player's inventory for the upgrade to appear. The tool will be destroyed when the upgrade is purchased.
TradeItemId (Optional) If set, the qualified or unqualified item ID for an extra item that must be traded to upgrade the tool. (For example, many vanilla tools need metal bars.)
TradeItemAmount (Optional) The number of TradeItemId required. Defaults to 1.
Condition (Optional) A game state query which indicates whether this upgrade is available. Defaults to always true.

For example, these are equivalent to the Steel Axe's upgrade settings:

"UpgradeFrom": [
    {
        "RequireToolId": "(T)CopperAxe",
        "Price": 5000,
        "TradeItemId": "(O)335", // Iron Bar
        "TradeItemAmount": 5
    }
]

If you want the tool to always be available, you can just omit the conditions. For example:

"UpgradeFrom": [
    {
        "Price": 5000
    }
]

Note that Clint needs a few days to smith the new tool. If you want to sell the tool directly, add it to a regular shop instead.

Game logic

field purpose
CanBeLostOnDeath Whether the player can lose this tool when they die. Default false.

Extensibility

field purpose
ModData (Optional) The mod data values to set when the tool is created, accessible in C# code via the tool.modData dictionary. For example:
"ModData": {
    "PowerLevel": 9000
}
SetProperties (Optional) Set the value of arbitrary properties on the tool class. For example, this would disable the tool animation and require no stamina:
"SetProperties": {
    "InstantUse": true,
    "IsEfficient": true
}

Weapons

Weapons are tools that can be used by the player to damage monsters.

They have their data in Data/Weapons, their in-game sprites in TileSheets/weapons, and their code in StardewValley.Tools.MeleeWeapon and StardewValley.Tools.Slingshot.

Data format

The weapon data in Data/Weapons consists of a string → model lookup, where...

  • The key is the unqualified item ID for the weapon.
  • The value is model with the fields listed below.

Basic weapon info

field effect
Name The internal weapon name.
DisplayName
Description
A tokenizable string for the translated display name & description.
Type The weapon type. One of 0 (stabbing sword), 1 (dagger), 2 (club or hammer), or 3 (slashing sword).

Appearance

field effect
Texture The asset name for the spritesheet containing the weapon's sprite.
SpriteIndex The index within the Texture for the weapon sprite, where 0 is the top-left sprite.

Stats

field effect
MinDamage
MaxDamage
The minimum and maximum based damage caused when hitting a monster with this weapon.
Knockback (Optional) How far the target is pushed when hit, as a multiplier relative to a base weapon like the Rusty Sword (e.g. 1.5 for 150% of Rusty Sword's weight). Default 1.
Speed (Optional) How fast the player can swing the weapon. Each point of speed is worth 40ms of swing time relative to 0. This stacks with the player's weapon speed. Default 0.
Precision (Optional) Reduces the chance that a strike will miss. Default 0.
Defense (Optional) Reduces damage received by the player. Default 0.
AreaOfEffect (Optional) Slightly increases the area of effect. Default 0.
CritChance (Optional) The chance of a critical hit, as a decimal value between 0 (never) and 1 (always). Default 0.02.
CritMultiplier (Optional) A multiplier applied to the base damage for a critical hit. This can be a decimal value. Default 3.

Game logic

field effect
CanBeLostOnDeath Whether the player can lose this tool when they die. Default true.
MineBaseLevel
MineMinLevel
(Optional) The base and minimum mine level, which affect mine container drops. Both default to -1, which disables automatic mine drops.

Advanced

field effect
Projectiles (Optional) The projectiles fired when the weapon is used, which continue along their path until they hit a monster and cause damage. A separate projectile is fired for each entry in this list.

This consists of a list of models with these fields (one projectile will fire for each entry in the list):

field effect
Id The unique string ID for the projectile within the current weapon's data.
Damage (Optional) The amount of damage caused when the projectile hits a monster. Default 10.
Explodes (Optional) Whether the projectile explodes when it collides with something. Default false.
Bounces (Optional) The number of times the projectile can bounce off walls before being destroyed. Default 0.
MaxDistance (Optional) The maximum tile distance the projectile can travel. Default 4.
Velocity (Optional) The speed at which the projectile moves. Default 10.
RotationVelocity (Optional) The rotation velocity. Default 32.
TailLength (Optional) The length of the tail which trails behind the main projectile. Default 1.
FireSound
BounceSound
CollisionSound
(Optional) The sound played when the projectile is fired, bounces off a wall, or collides with something. All three default to none.
MinAngleOffset
MaxAngleOffset
(Optional) A random offset applied to the direction of the project each time it's fired. Both fields default to 0, in which case it's always shot at the 90° angle matching the player's facing direction.
SpriteIndex (Optional) The sprite index in the TileSheets/Projectiles asset to draw for this projectile. Defaults to 11 (a glowing-yellow-ball sprite).
Item (Optional) The item to shoot. If set, this overrides SpriteIndex.

This consists of a list of models with these fields:

field effect
common fields See item spawn fields for the generic item fields supported for ammo items.

If set to an item query which returns multiple items, one of them will be selected at random.

Note that these are magic projectiles fired when the weapon is used, they're not aimed directly like slingshot projectiles.

CustomFields The custom fields for this entry.

Weapons have a hardcoded category of -98 (Object.weaponCategory).

Slingshot notes

  • The base slingshot has ParentSheetIndex 32 in the weapon data, which increases by one for each upgrade level (up to 34 in the weapon data, though only 32 and 33 are obtainable without mods).
  • Slingshot damage is calculated dynamically regardless of the weapon data.

Mine container drops

When the player breaks a container in the mines, there's a chance it will drop a weapon. Here's how the weapon to drop is chosen[1]:

  1. Match weapons whose minimum mine level is less than the current mine level.
  2. From that list, match weapons with a probability check based on the gap between the base mine level and current mine level. The probability is a bell curve centered on the base mine level:
    level difference probability
    0 100%
    5 92%
    10 71%
    15 46%
    20 25%
    25 4%
    The difference applies in both directions; for example, two weapons whose base levels are 5 below and 5 above the current level both have a 92% chance. (The probability is calculated with a Gaussian function e-(current mine level - base mine level)2 / (2 * 122).)
  3. Find the weapon with the smallest gap between the current and base mine levels, and add it to the list. (If the item was also selected in step 2, it has two chances to drop.)
  4. From the remaining list of weapons, randomly choose one to drop.

See also

References

  1. See Utility.getUncommonItemForThisMineLevel in the game code.

History

  • 1.6: Objects are now stored in Data/Objects rather than Data/ObjectInformation and have a new format.
  • 1.6: Field 4 of hats is now used for tags, rather than displayName.
  • 1.6: Display name field is now used for all languages.
  • 1.6: Added Texture & texture index fields to all object data.
  • 1.6: All types of items now use string IDs.