Modding:Objects: Difference between revisions
imported>Pathoschild split common info to Modding:Items |
imported>Zeltron0012 m removed a duplicate mention of CombatLevel in custom attributes |
||
| (18 intermediate revisions by 7 users not shown) | |||
| Line 1: | Line 1: | ||
← [[Modding:Items|Items]] | ← [[Modding:Items|Items]] | ||
This page explains how the game stores and parses item data. | This page explains how the game stores and parses object-type item data. For items in general, see [[Modding:Items]]. | ||
== | ==Overview== | ||
Objects are the default type for items in inventories or | Objects are the default type for items in inventories or in the world. Depending on their data, they can be placed, picked up, eaten, sold to shops, etc. | ||
They have | They have [[Modding:Items#Item types|item type]] <code>(O)</code> (or <code>ItemRegistry.type_object</code> in C# code), their data in <samp>Data/Objects</samp>, their icon sprites in <samp>Maps/springobjects</samp> or <samp>TileSheets/Objects_2</samp> by default, and their code in <samp>StardewValley.Object</samp>. See [[/Object sprites|a table of sprites and their corresponding indexes]]. | ||
==Data format== | |||
The object data in <samp>Data/Objects</samp> consists of a string → model lookup, where... | The object data in <samp>Data/Objects</samp> consists of a string → model lookup, where... | ||
* The key is the unqualified [[Modding: | * The key is the unqualified [[Modding:Common data field types#Item ID|item ID]]. | ||
* The value is a model with the fields listed below. | * The value is a model with the fields listed below. | ||
===Basic info=== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 26: | Line 26: | ||
|- | |- | ||
| <samp>Type</samp> | | <samp>Type</samp> | ||
| The item's general type, like Arch (artifact) or Minerals. The vanilla types are: Litter, | | The item's general type, like Arch (artifact) or Minerals. The vanilla types are: <samp>Basic</samp>, <samp>Arch</samp> (artifact), <samp>Litter</samp> (e.g. debris), <samp>Minerals</samp>, <samp>Quest</samp>, <samp>Crafting</samp>, <samp>Fish</samp>, <samp>Cooking</samp>, <samp>Seeds</samp>, <samp>Ring</samp>, <samp>interactive</samp>, and some placeholder values like <samp>asdf</samp>. | ||
'''Caution:''' adding custom items with the <samp>Arch</samp> type is inadvisable as it often leads to [[Artifact Spot|artifact spot]]s becoming broken and not giving any items. | |||
'''Note:''' The "Type" affects whether an item shows up in the collections menu. For example, items with <samp>Type: Cooking</samp> will show up as silhouettes in the cooked items collection menu, items with <samp>Type: Minerals</samp> will show up as silhouettes in the mineral collection menu, etc. However, the [[Modding:Items#Categories|Category]] of the item must also be the correct number or the item will not count toward Perfection/Achievements. For example, if an item has Type: Cooking, it must also be "Category": -7 in order to count toward the "Gourmet Chef" achievement and Perfection. | |||
|- | |- | ||
| <samp>Category</samp> | | <samp>Category</samp> | ||
| Line 35: | Line 39: | ||
|} | |} | ||
===Appearance=== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 46: | Line 50: | ||
| <samp>SpriteIndex</samp> | | <samp>SpriteIndex</samp> | ||
| The sprite's index within the <samp>Texture</samp>, where 0 is the top-left sprite. | | The sprite's index within the <samp>Texture</samp>, where 0 is the top-left sprite. | ||
|- | |||
| <samp>ColorOverlayFromNextIndex</samp> | |||
| ''(Optional)'' When drawn as a colored object, whether to apply the color to the next sprite in the spritesheet and draw that over the main sprite. If false, the color is applied to the main sprite instead. Default false. | |||
|} | |} | ||
===Edibility=== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 84: | Line 91: | ||
! result | ! result | ||
|- | |- | ||
| <samp>Duration</samp><br /><samp>IconTexture</samp><br /><samp> | | <samp>Duration</samp><br /><samp>IconTexture</samp><br /><samp>IconSpriteIndex</samp><br /><samp>GlowColor</samp> | ||
| If specified, the value in <samp>Data/Objects</samp> is used instead of the one in <samp>Data/Buffs</samp>. If omitted, defaults to the value from <samp>Data/Buffs</samp>. | | If specified, the value in <samp>Data/Objects</samp> is used instead of the one in <samp>Data/Buffs</samp>. If omitted, defaults to the value from <samp>Data/Buffs</samp>. | ||
|- | |- | ||
| Line 100: | Line 107: | ||
| ''(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 <samp>BuffId</samp> and <samp>CustomAttributes</samp> fields. | | ''(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 <samp>BuffId</samp> and <samp>CustomAttributes</samp> fields. | ||
|- | |- | ||
| <samp> | | <samp>IconSpriteIndex</samp> | ||
| ''(Optional)'' The buff's icon index within the <samp>IconTexture</samp>, where 0 is the top-left icon. Default 0. | | ''(Optional)'' The buff's icon index within the <samp>IconTexture</samp>, where 0 is the top-left icon. Default 0. | ||
|- | |- | ||
| <samp>GlowColor</samp> | | <samp>GlowColor</samp> | ||
| ''(Optional)'' The glow color to apply to the player. See [[Modding: | | ''(Optional)'' The glow color to apply to the player. See [[Modding:Common data field types#Color|color format]]. Default none. | ||
|- | |- | ||
| <samp>CustomAttributes</samp> | | <samp>CustomAttributes</samp> | ||
| Line 115: | Line 122: | ||
! purpose | ! purpose | ||
|- | |- | ||
| <samp>FarmingLevel</samp><br /><samp>FishingLevel</samp><br /><samp>ForagingLevel</samp><br /><samp>LuckLevel</samp><br /><samp>MiningLevel</samp> | | <samp>CombatLevel</samp><br /><samp>FarmingLevel</samp><br /><samp>FishingLevel</samp><br /><samp>ForagingLevel</samp><br /><samp>LuckLevel</samp><br /><samp>MiningLevel</samp> | ||
| ''(Optional)'' An amount applied to the matching [[Skills|skill level]] while the buff is active. This can be negative for a debuff. Default 0. | | ''(Optional)'' An amount applied to the matching [[Skills|skill level]] while the buff is active. This can be negative for a debuff. Default 0. | ||
|- | |- | ||
| <samp>Attack</samp><br /><samp>Defense</samp><br /><samp>MagneticRadius</samp><br /><samp>MaxStamina</samp><br /><samp>Speed</samp> | | <samp>Attack</samp><br /><samp>AttackMultiplier</samp><br /><samp>CriticalChanceMultiplier</samp><br /><samp>CriticalPowerMultiplier</samp><br /><samp>Defense</samp><br /><samp>Immunity</samp><br /><samp>KnockbackMultiplier</samp><br /><samp>MagneticRadius</samp><br /><samp>MaxStamina</samp><br /><samp>Speed</samp><br /><samp>WeaponPrecisionMultiplier</samp><br /><samp>WeaponSpeedMultiplier</samp> | ||
| ''(Optional)'' An amount applied to the player's [[attack]], [[defense]], [[Magnetism|magnetic radius]], maximum [[Energy|stamina]], or [[speed]] while the buff is active. This can be negative for a debuff. Default 0. | | ''(Optional)'' An amount applied to the player's [[attack]], [[Crit. Chance|critical chance]] and [[Crit. Power|critical power]], [[defense]], [[immunity]], knockback (i.e. [[weight]]), [[Magnetism|magnetic radius]], maximum [[Energy|stamina]], [[speed]], or weapon precision/[[speed|speed]] while the buff is active. This can be negative for a debuff. Default 0. | ||
|} | |} | ||
|- | |- | ||
| <samp>CustomFields</samp> | | <samp>CustomFields</samp> | ||
| ''(Optional)'' The [[Modding: | | ''(Optional)'' The [[Modding:Common data field types#Custom fields|custom fields]] for this entry. | ||
|} | |} | ||
|} | |} | ||
===Geodes & artifact spots=== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 160: | Line 167: | ||
For consistency, vanilla drops mostly use these values: | For consistency, vanilla drops mostly use these values: | ||
* <samp>-1000</samp>: special overrides like the [[Golden Helmet]]; | * <samp>-1000</samp>: special overrides like the [[Golden Helmet|golden helmet]]; | ||
* <samp>0</samp>: normal items. | * <samp>0</samp>: normal items. | ||
|}</li> | |}</li> | ||
| Line 176: | Line 183: | ||
|} | |} | ||
===Context tags & exclusions=== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 183: | Line 190: | ||
|- | |- | ||
| <samp>ContextTags</samp> | | <samp>ContextTags</samp> | ||
| ''(Optional)'' The custom [[Modding: | | ''(Optional)'' The custom [[Modding:Context tags|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: | ||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
"ContextTags": [ "color_yellow", "fish_ocean", "fish_upright", "season_summer" ] | "ContextTags": [ "color_yellow", "fish_ocean", "fish_upright", "season_summer" ] | ||
| Line 192: | Line 199: | ||
|- | |- | ||
| <samp>CanBeTrashed</samp> | | <samp>CanBeTrashed</samp> | ||
| ''(Optional)'' Whether this item can be trashed from the player's inventory. Default true. | | ''(Optional)'' Whether this item can be trashed from the player's inventory. Also affects whether the item can be shipped but not whether it can be sold to shops. Default true. | ||
|- | |- | ||
| <samp>ExcludeFromRandomSale</samp> | | <samp>ExcludeFromRandomSale</samp> | ||
| Line 198: | Line 205: | ||
|- | |- | ||
| <samp>ExcludeFromFishingCollection</samp><br /><samp>ExcludeFromShippingCollection</samp> | | <samp>ExcludeFromFishingCollection</samp><br /><samp>ExcludeFromShippingCollection</samp> | ||
| ''(Optional)'' Whether to exclude this item from the fishing/shipping collection and their respective effect on the [[perfection|perfection score]]. Default false, in which case the normal requirements apply (e.g. artifacts are always excluded from the shipping collection). | | ''(Optional)'' Whether to exclude this item from the fishing/shipping collection and their respective effect on the [[perfection|perfection score]]. Default false, in which case the normal requirements apply (e.g., artifacts are always excluded from the shipping collection). | ||
|} | |} | ||
===Advanced=== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 208: | Line 215: | ||
|- | |- | ||
| <samp>CustomFields</samp> | | <samp>CustomFields</samp> | ||
| ''(Optional)'' The [[Modding: | | ''(Optional)'' The [[Modding:Common data field types#Custom fields|custom fields]] for this entry. | ||
|} | |} | ||
== | ==Unobtainable items== | ||
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. | |||
==For C# mods== | |||
Object-type items are represented by the <samp>StardewValley.Object</samp> type. | |||
This provides many methods to simplify common logic. Some notable examples: | |||
{| class="wikitable" | |||
|- | |||
! method | |||
! effect | |||
|- | |||
| <samp>Object.GetRadiusForScarecrow()</samp> | |||
| The tile radius that Object protects as a scarecrow. Default behavior: Checks for the value in the <samp>crow_scare_radius_{{t|radius}}</samp> [[Modding:Context tags|context tag]] if applicable, then defaults to 17 if the internal name contains "Deluxe" and 9 otherwise. Can be patched to support custom scarecrows. | |||
|- | |||
| <samp>Object.IsBar()</samp> | |||
| Whether the item is a [[Copper Bar|copper bar]], [[Iron Bar|iron bar]], [[Gold Bar|gold bar]], [[Iridium Bar|iridium bar]], or [[Radioactive Bar|radioactive bar]]. | |||
|- | |||
| <samp>Object.IsBreakableStone()</samp> | |||
| Whether the item is a stone debris item which can be broken by a pickaxe. | |||
|- | |||
| <samp>Object.IsFence()</samp> | |||
| Whether the item is a [[Crafting#Fences|fence]]. | |||
|- | |||
| <samp>Object.IsFruitTreeSapling()</samp> | |||
| Whether the item is a [[Fruit Trees|fruit tree]] sapling. This checks the <samp>Data\fruitTrees</samp> keys, so it works with custom fruit trees too. | |||
|- | |||
| <samp>Object.IsHeldOverHead()</samp> | |||
| Whether the player is shown holding up the item when it's selected in their toolbar. Default true (except for furniture). | |||
|- | |||
| <samp>Object.IsIncubator()</samp> | |||
| Whether the item can incubate [[Animals|farm animal]] eggs when placed in a building. | |||
|- | |||
| <samp>Object.IsScarecrow()</samp> | |||
| Whether the item is a scarecrow. Default: <samp>true</samp> if the object has the <samp>crow_scare</samp> [[Modding:Context_tags|context tag]]. Otherwise, returns whether the object's internal name contains "arecrow". Can be patched to support custom scarecrows. | |||
|- | |||
| <samp>Object.IsTapper()</samp> | |||
| Whether the item is a [[Tapper|tapper]] or [[Heavy Tapper|heavy tapper]]. | |||
|- | |||
| <samp>Object.IsTeaSapling()</samp> | |||
| Whether the item is a [[Tea Sapling|tea sapling]]. | |||
|- | |||
| <samp>Object.IsTwig()</samp> | |||
| Whether the item is a twig debris item. | |||
|- | |||
| <samp>Object.IsWeeds()</samp> | |||
| Whether the item is a weed debris item. | |||
|} | |||
==See also== | ==See also== | ||
* [[Modding: | * [[Modding:Items]] for item data in general | ||
[[Category:Modding]] | [[Category:Modding]] | ||
[[ru:Модификации:Объекты]] | [[ru:Модификации:Объекты]] | ||
[[zh:模组:物体]] | |||
Latest revision as of 10:59, 8 August 2026
← Items
This page explains how the game stores and parses object-type item data. For items in general, see Modding:Items.
Overview
Objects are the default type for items in inventories or in the world. Depending on their data, they can be placed, picked up, eaten, sold to shops, etc.
They have item type (O) (or ItemRegistry.type_object in C# code), their data in Data/Objects, their icon sprites in Maps/springobjects or TileSheets/Objects_2 by default, 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: Basic, Arch (artifact), Litter (e.g. debris), Minerals, Quest, Crafting, Fish, Cooking, Seeds, Ring, interactive, and some placeholder values like asdf.
Caution: adding custom items with the Arch type is inadvisable as it often leads to artifact spots becoming broken and not giving any items. Note: The "Type" affects whether an item shows up in the collections menu. For example, items with Type: Cooking will show up as silhouettes in the cooked items collection menu, items with Type: Minerals will show up as silhouettes in the mineral collection menu, etc. However, the Category of the item must also be the correct number or the item will not count toward Perfection/Achievements. For example, if an item has Type: Cooking, it must also be "Category": -7 in order to count toward the "Gourmet Chef" achievement and Perfection. |
| 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. |
| ColorOverlayFromNextIndex | (Optional) When drawn as a colored object, whether to apply the color to the next sprite in the spritesheet and draw that over the main sprite. If false, the color is applied to the main sprite instead. Default false. |
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:
|
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:
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:
|
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" ]
|
| CanBeGivenAsGift | (Optional) Whether this item can be gifted to NPCs. Default true. |
| CanBeTrashed | (Optional) Whether this item can be trashed from the player's inventory. Also affects whether the item can be shipped but not whether it can be sold to shops. Default true. |
| 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. |
Unobtainable items
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.
For C# mods
Object-type items are represented by the StardewValley.Object type.
This provides many methods to simplify common logic. Some notable examples:
| method | effect |
|---|---|
| Object.GetRadiusForScarecrow() | The tile radius that Object protects as a scarecrow. Default behavior: Checks for the value in the crow_scare_radius_<radius> context tag if applicable, then defaults to 17 if the internal name contains "Deluxe" and 9 otherwise. Can be patched to support custom scarecrows.
|
| 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.IsScarecrow() | Whether the item is a scarecrow. Default: true if the object has the crow_scare context tag. Otherwise, returns whether the object's internal name contains "arecrow". Can be patched to support custom scarecrows. |
| Object.IsTapper() | Whether the item is a tapper or heavy tapper. |
| Object.IsTeaSapling() | Whether the item is a tea sapling. |
| Object.IsTwig() | Whether the item is a twig debris item. |
| Object.IsWeeds() | Whether the item is a weed debris item. |
See also
- Modding:Items for item data in general