Jump to content

Modding:Objects: Difference between revisions

From Stardew Valley Wiki
imported>Pathoschild
merge Modding:Hat data into page as-is (initial content by Margotbean, ignoreHairStyleOffset info by MonaisReal, data updates by MouseyPounds + Pathoschild + Spaceeinstein + Treyh0)
imported>Pathoschild
→Hats: expand info, replace raw data with example, rewrite to fit unified page
Line 517: Line 517:
|}
|}


=Hats=
==Hats==
This page explains how the game stores and parses hat data. This is an advanced guide for mod developers.
Hats are items that can be equipped in the player's [[hats|hat]] slot.


==Raw data==
They have their data in <samp>Data/Hats</samp>, their in-game sprites in <samp>Characters/Farmer/hats</samp>, and their code in <samp>StardewValley.Objects.Hat</samp>.
Hat data is stored in <samp>Content\Data\hats.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:


{{collapse|Data|content=<syntaxhighlight lang="json">
===Data format===
{
The hat data in <samp>Data/Hats</samp> consists of an integer→string dictionary with entries like this:
  "0": "Cowboy Hat/The leather is old and cracked, but surprisingly supple. It smells musty./false/true",
  "1": "Bowler Hat/Made from smooth felt./false/true",
  "2": "Top Hat/A gentleman's classic./false/true",
  "3": "Sombrero/A festively decorated hat made from woven straw./false/true",
  "4": "Straw Hat/Light and cool, it's a farmer's delight./false/true",
  "5": "Official Cap/Looks like it belonged to a postman or policeman. Either way, it's still very soft and smells okay./false/true",
  "6": "Blue Bonnet/Harken back to simpler times with this prairie bonnet./false/true",
  "7": "Plum Chapeau/Looks alright./false/true",
  "8": "Skeleton Mask/The red eyes are glowing mysteriously./true/true",
  "9": "Goblin Mask/Freak out the neighborhood with this creepy mask. Rubber ear joints for effect./true/true",
  "10": "Chicken Mask/You'll be sure to get them grinning with this one./true/true",
  "11": "Earmuffs/Keep your ears toasty. Lined with artisanal velvet from Castle Village./true/false",
  "12": "Delicate Bow/Little pink jewels glisten as you examine it./true/false",
  "13": "Tropiclip/It's shaped like a little palm tree./true/false",
  "14": "Butterfly Bow/This one is very soft./true/false",
  "15": "Hunter's Cap/The wool lining should stay warm deep into the forest./false/true",
  "16": "Trucker Hat/Mesh in the back to keep your head cool./false/true",
  "17": "Sailor's Cap/It's fresh and starchy./false/true",
  "18": "Good Ol' Cap/A floppy old topper with a creased bill. Looks like it's been through a lot./false/true",
  "19": "Fedora/A city-slicker's standard./false/true",
  "20": "Cool Cap/It looks really faded, but it used to be a vibrant blue./false/true",
  "21": "Lucky Bow/The middle is made of solid gold./true/false",
  "22": "Polka Bow/This one's sure to be turn heads./true/false",
  "23": "Gnome's Cap/This gnome had a very large head./false/true",
  "24": "Eye Patch/You can't tell if it's real or just from a costume shop./true/true",
  "25": "Santa Hat/Celebrate the magical season./false/true",
  "26": "Tiara/This one has a big amethyst encircled by gold./true/true",
  "27": "Hard Hat/Keep your dome in one piece./false/true",
  "28": "Sou'wester/The shape helps to keep sailors dry during storms./false/true",
  "29": "Daisy/A fresh spring daisy to put in your hair./true/false",
  "30": "Watermelon Band/The color scheme was inspired by the beloved summer melon./true/false",
  "31": "Mouse Ears/Made from synthetic fibers./true/true",
  "32": "Cat Ears/Whiskers included./true/true",
  "33": "Cowgal Hat/The band is studded with fake diamonds./false/true",
  "34": "Cowpoke Hat/For dairy experts./false/true",
  "35": "Archer's Cap/Fashionable whether you're an archer or not./false/true",
  "36": "Panda Hat/A lovely panda hat./false/true",
  "37": "Blue Cowboy Hat/A denim cowboy hat in cool blue./false/true",
  "38": "Red Cowboy Hat/An eye-catching cowboy hat in red suede./false/true",
  "39": "Cone Hat/A curiosity from a distant land./false/true",
  "40": "Living Hat/It absorbs moisture from your scalp. No watering needed!/false/true",
  "41": "Emily's Magic Hat/Made with love by Emily. It's 100% organic!/false/true",
  "42": "Mushroom Cap/It smells earthy./false/true",
  "43": "Dinosaur Hat/A hat fashioned to look like a small dinosaur./false/true",
  "44": "Totem Mask/Don't worry, it won't warp your face.../true/true",
  "45": "Logo Cap/A red cap with a logo on the front./false/true",
  "46": "Wearable Dwarf Helm/A slightly larger, human sized version of the helmets worn by dwarves./hide/true",
  "47": "Fashion Hat/A fashionable hat with a feather in the brim./false/true",
  "48": "Pumpkin Mask/This must have been a pretty big pumpkin once.../hide/true",
  "49": "Hair Bone/A prehistoric version of the hair bow./true/false",
  "50": "Knight's Helmet/It looks just like the real thing!/hide/true",
  "51": "Squire's Helmet/The face is exposed to increase air flow./hide/true",
  "52": "Spotted Headscarf/A red polka-dot scarf tied around the head./hide/true",
  "53": "Beanie/A warm hat with a pretty tight fit./hide/true",
  "54": "Floppy Beanie/A warm hat with a looser fit./hide/true",
  "55": "Fishing Hat/The wide brim keeps you shaded when you're fishing on the riverbank./false/true",
  "56": "Blobfish Mask/Just as spongy as the real thing!/true/true",
  "57": "Party Hat/A goofy red hat that makes any celebration more fun./false/true",
  "58": "Party Hat/A goofy blue hat that makes any celebration more fun./false/true",
  "59": "Party Hat/A goofy green hat that makes any celebration more fun./false/true",
  "60": "Arcane Hat/The type of cowboy hat worn by a wizard./false/true",
  "61": "Chef Hat/The traditional hat worn by a head chef./hide/true",
  "62": "Pirate Hat/A captain's hat with a horrible skull on the front./false/true",
  "63": "Flat Topped Hat/An old style of hat once considered very fashionable./false/true",
  "64": "Elegant Turban/A fine black silk turban with gold trim./false/true",
  "65": "White Turban/A fine white silk turban with blue trim./false/true",
  "66": "Garbage Hat/It's a garbage can lid 'upcycled' into a hat.../false/true",
  "67": "Golden Mask/A faithful recreation of the Calico Desert relic!/true/true",
  "68": "Propeller Hat/A goofy hat with a propeller on top./false/true",
  "69": "Bridal Veil/The traditional headwear for a bride./false/true",
  "70": "Witch Hat/A pointy hat popular with witches./false/true",
  "71": "Copper Pan/You place the copper pan on your head.../false/true",
  "72": "Green Turban/A green silk turban with a gold ornament on the front./false/true",
  "73": "Magic Cowboy Hat/It's shimmering with prismatic energy/false/true/Prismatic",
  "74": "Magic Turban/It's shimmering with prismatic energy/false/true/Prismatic",
  "75": "Golden Helmet/It's half of a golden coconut./false/true",
  "76": "Deluxe Pirate Hat/Only the most infamous pirate could pull off this look./false/true",
  "77": "Pink Bow/This huge bow makes quite a statement!/true/false",
  "78": "Frog Hat/A slimy friend that lives on your dome./hide/true",
  "79": "Small Cap/It's a more aerodynamic style of cap./false/true",
  "80": "Bluebird Mask/Wear this to look just like your favorite island trader./hide/true",
  "81": "Deluxe Cowboy Hat/A cowboy hat with a more extreme shape./false/true",
  "82": "Mr. Qi's Hat/A replica of Mr. Qi's iconic hat./false/true",
  "83": "Dark Cowboy Hat/A cowboy hat in fashionable black./false/true",
  "84": "Radioactive Goggles/Doesn't actually provide any protection from radiation./true/true",
  "85": "Swashbuckler Hat/The classic swashbuckler look./false/true",
  "86": "Qi Mask/???/hide/true",
  "87": "Star Helmet/A red hat with stars on it./false/true",
  "88": "Sunglasses/These give you a relaxed look./true/true",
  "89": "Goggles/These will make you look very safe./true/true",
  "90": "Forager's Hat/It's a forager's delight./false/true",
  "91": "Tiger Hat/Makes you look like a beautiful tiger./hide/true",
  "92": "???/???/hide/true",
  "93": "Warrior Helmet/An Ostrich eggshell repurposed into a helmet./false/true"
}
</syntaxhighlight>}}


==Format==
<syntaxhighlight lang="json">
  "5": "Official Cap/Looks like it belonged to a postman or policeman. Either way, it's still very soft and smells okay./false/true"
</syntaxhighlight>
 
For each entry in the data asset, the key is the item's <samp>ParentSheetIndex</samp> and the value is a slash-delimited string with these fields:


Hats have a hard-coded category of -95 (<samp>Hats.cs::Load</samp>)
{| class="wikitable"
{| class="wikitable"
|-
|-
! Index
! index
! Field
! field
! Example Value
! effect
|-
|-
| 0
| 0
| Name
| name
| ''Trucker Hat''
| The internal item name (and display name in English).
|-
|-
| 1
| 1
| Description
| description
| ''Mesh in the back to keep your head cool.''
| The translated item description shown in-game.
|-
|-
| 2
| 2
| skipHairDraw
| show real hair
| ''false''
| Whether to show the player's hairstyle as-is when the hat is worn (<samp>true</samp>), or change the hairstyle to fit the hat (<samp>false</samp>).
|-
|-
| 3
| 3
| ignoreHairstyleOffset
| skip hairstyle offset
| ''true''
| Whether to ignore the current style when positioning the hat (one of <samp>true</samp> or <samp>false</samp>). For example, the [[Eye Patch|eye patch]] sets <samp>true</samp> since its position isn't affected by the hair, but the [[Butterfly Bow|butterfly bow]] sets <samp>false</samp> to adjust its position on top of your hair.
|-
|-
| 4
| 4
| Name (for language files other than English)
| display name
| ''Truckerhut''
| The translated item name shown in-game (for non-English assets only).
|}
|}


If skipHairDraw is "true", then the game will not change the character's hairstyle when they put on the hat.  If set to "false", the player's hairstyle may change when they put on the hat.
Hats have a hard-coded category of -95 (<samp>Hats.cs::Load</samp>)
 
If ignoreHairstyleOffset is set to "true", it means that the game will position the hat regardless of the hairstyle your character has. For instance, for a hat such as the Butterfly Bow, you will want to have it set to "false" so that the bow will adjust position to be attached to your character's chosen hairstyle. However, for something like the Eye Patch, that should be kept in the same position on your character's head no matter what hair you have chosen, so it should be set to "true".


==See also==
==See also==

Revision as of 03:03, 28 January 2022

← Index

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

Introduction

Overview

Items are divided into several types:

item type data asset texture name summary
Object Data/ObjectInformation Maps/springobjects The default type for items in inventories or placed in the world.
Object (big craftable) Data/BigCraftablesInformation TileSheets/Craftables Craftable items which can be placed in the world and are two tiles tall (instead of one like objects).
Boots Data/Boots item sprite: Maps/springobjects
shoe color: Characters/Farmer/shoeColors
Equippable boots.
Clothing Data/ClothingInformation Characters/Farmer/pants
Characters/Farmer/shirts
Equippable pants and shirts.
Furniture Data/Furniture TileSheets/furniture Decorative furniture items, including chairs which the player can sit on.
Hat Data/Hats Characters/Farmer/hats Equippable hat items.
Tool — TileSheets/Tools Tools that can be used by the player.
MeleeWeapon Data/Weapons TileSheets/weapons Weapons that can be used by the player to damage monsters.

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

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

See the sections below for details on each item type.

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 English translation
-2 Object.GemCategory Mineral
-4 Object.FishCategory Fish
-5 Object.EggCategory Animal Product
-6 Object.MilkCategory Animal Product
-7 Object.CookingCategory Cooking
-8 Object.CraftingCategory Crafting
-9 Object.BigCraftableCategory
-12 Object.mineralsCategory Mineral
-14 Object.meatCategory Animal Product
-15 Object.metalResources Resource
-16 Object.buildingResources Resource
-17 Object.sellAtPierres
-18 Object.sellAtPierresAndMarnies Animal Product
-19 Object.fertilizerCategory Fertilizer
-20 Object.junkCategory Trash
-21 Object.baitCategory Bait
-22 Object.tackleCategory Fishing Tackle
-23 sellAtFishShopCategory
-24 Object.furnitureCategory Decor
-25 Object.ingredientsCategory Cooking
-26 Object.artisanGoodsCategory Artisan Goods
-27 Object.syrupCategory Artisan Goods
-28 Object.monsterLootCategory Monster Loot
-29 Object.equipmentCategory
-74 Object.SeedsCategory Seed
-75 Object.VegetableCategory Vegetable
-79 Object.FruitsCategory Fruit
-80 Object.flowersCategory Flower
-81 Object.GreensCategory Forage
-95 Object.hatCategory
-96 Object.ringCategory
-98 Object.weaponCategory
-99 Object.toolCategory
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.objectInformation.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))}`));

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

Every item must be assigned a unique ParentSheetIndex within its type, and that index must fit within the item type's spritesheet.

Adding custom items to the data assets and spritesheets directly is not recommended, since it's very easy to conflict with other mods or cause game errors. Instead you should create a content pack for Json Assets, which coordinates dynamic item ID assignment so multiple custom item mods can work together.

Objects

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

They have their data in Data/ObjectInformation, 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/ObjectInformation consists of an integer→string dictionary with entries like this:

  "18": "Daffodil/30/0/Basic -81/Daffodil/A traditional spring flower that makes a nice gift."

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with the fields listed below. Fields 0–5 are used by rings and most other objects; fields 6–11 are only used for food buffs. The objects with keys 516–534 (Ring.ringLowerIndexRange through Ring.ringUpperIndexRange) and 801 (wedding ring) are hardcoded as rings.

index field effect
all objects
0 name The internal item name (and display name in English).
1 price The gold price of the item when sold by the player.
2 edibility A numeric value that determines how much health (edibility × 2.5) and energy (edibility × 1.125) is restored. An item with an edibility of -300 can't be eaten.

This is ignored for rings.

3 type and category
  • For a ring: the value Ring. Rings have a hardcoded category of -96 (Object.ringCategory).
  • For other objects: the item's type (string) and category (negative integer), separated by a space like Fish -4.
4 display name The translated item name.
5 description The translated item description.
food & drink only
6 miscellaneous
  • For a food or drink item, set this to food or drink respectively. This enables the remaining fields, and changes which animation/sound is played when the player consumes the item. Any other value is ignored.
  • For a geode item (535, 536, 537, or 749) is broken, a space-delimited list of object IDs. There's a roughly 50% chance that the geode item will drop one of these items (the other drops are hardcoded).
7 buffs The bonuses to apply to the player's attribute when the item is consumed. This consists of a space-delimited list of these numbers:
index buff
0 farming
1 fishing
2 mining
3 unused
4 luck
5 foraging
6 unused
7 max energy
8 magnetism
9 speed
10 defense
11 attack
8 buff duration How long the buffs provided by the previous field last. This is converted into in-game minutes using the formula (duration × 0.7) / 60. The buff duration number shown in-game will always be one second less than the calculated value.

Notes

  • Items that have a number in the "Crafting" field show buggy information in-game (e.g., Bean Hotpot prior to version 1.4). Items that have a number in the "Attack" field display the Attack icon and a number, but no description. It's unclear how these buffs work (if at all).
  • 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.

Objects (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/BigCraftableInformation, their in-game sprites in TileSheets/Craftables, and their code in StardewValley.Object (with the bigCraftable.Value = true flag).

Data format

The big craftables data in Data/BigCraftableInformation consists of an integer→string dictionary with entries like this:

  "19": "Oil Maker/50/-300/Crafting -9/Makes gourmet truffle oil./true/true/0/Oil Maker"

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 price The gold price when sold by the player.
2 edibility See edibility for object data. Always set to -300 (inedible) for vanilla items.
3 type and category See type and category for object data. Always set to Crafting -9 for vanilla items.
4 description The translated item description shown in-game.
5 outdoors Whether the item can be placed outdoors (true or false).
6 indoors Whether the item can be placed indoors (true or false).
7 fragility How the item is removed by tools. Possible values:
fragility effect
0 Pick up with any tool.
1 Destroyed if hit with an axe, hoe, or pickaxe. Any other tool will pick it up.
2 Indestructible. The item can't be removed once placed.
8 is lamp Whether the item is a lamp and produces light when it's dark. This can be true (mark as lamp) or any other value (ignored).
9 display name The translated display name (in non-English assets only).

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.

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

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 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 display name The translated item name shown in-game (for non-English assets only).

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

See also