Question: How do you add objects to r188?

Hi

Here’s the break down currently for r180, feel free to ask anyone if you have any more questions :wink:

edit:
I assumed craftable, if not let us know. World gen is somewhat similar, but still very doable at this point.

Step 1 - Basic Setup


Goto your Stonehearth mods folder, if you installed to the default location this should be

x86 - 32bit
C:\Program Files\Steam\SteamApps\common\Stonehearth\mods

x64 - 64 bit
C:\Program Files (x86)\Steam\SteamApps\common\Stonehearth\mods

Now create a folder for your mod, for this example I’ll create a folder called r180mod.

Next create a file inside your mod folder, mine is r180mod, called manifest.json.
Open your manifest.json, we will be using it in a little bit.

Now lets add you items files into our mod folder (r180mod).

For conventions sake, we add a “entities” folder, “entities” will be used to store all the files for items we add to the game. “entities” should be place just inside our r180mod folder.

Next add another folder for your mod item inside the entities folder. I will call mine “my_mod_item”.
Now add any .qb files .png files that you’ve made for that item inside that folder.

Our mod file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----my_mod_item
          ----my_mod_item.qb
          ----my_mod_item_iconic.qb
          ----my_mod_item.png

Let me break down the files I’ve added

my_mod_item_iconic.qb - The stockpile version of my model, I believe it’s 10x10x10 voxels
my_mod_item.qb - The actual fullsize model of my item
my_mod_item.png - The picture displayed in the crafting window.

Step 2 - Basic Manifest set up


Now lets go back to that manifest.json file, this file is used to tell Stonehearth many things about files you would like to it load, in particular we are concerned with the mixintos and aliases properties.

mixintos - used to combine an existing file with another
aliases - allow us to give a simplified name for our mod item, just to simplify referencing it latter on.

Here is an example of a basic mod manifest

{
    "info" : {
          "name" : "r180mod",
          "version" : 1
    },
    "aliases" : {
    },
    "mixintos" : {
    }
}

You should copy and paste this to your manifest.json.
Just replace the “name” value with you mods folder name.

Lets add an alias for our mod item

{
    "info" : {
          "name" : "r180mod",
          "version" : 1
    },
    "aliases" : {
          "my_mod_item" : "file(entities/my_mod_item/my_mod_item.json)"
    },
    "mixintos" : {
    }
}

Step 3 - Mixintos/Recipes


Next in order for your item to be craftable in the game, we must mixinto a classes recipe list. In order to do so we must have the files needed for the mixin and know where to mix into.

Where - This depends on which class will crafting your item, all classes can be found in stonehearth/jobs
The Files - We will go over this together

Just follow along, I explain everything in the end.

Lets use the carpenter for this example, lets create a new folder to hold all of our mixintos called “mixins”, place this inside r180mod.

Inside our mixins folder lets create a file called “carpenter_recipes.json”.

Now step back to the r180mod folder and create another folder called "recipes", inside this folder create another file called “my_mod_item_recipe.json”.

carpenter_recipes.json - Will be used to specify all of the recipes we’d like to add to carpenters current recipe list.
my_mod_item_recipe.json - Will be used to specify the acutally recipe for our item.

Our mod file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----my_mod_item
          ----my_mod_item.qb
          ----my_mod_item_iconic.qb
          ----my_mod_item.png
  ----mixins -NEW
      ----carpenter_recipes.json -NEW
  ----recipes -NEW
      ----my_mod_item_recipe.json -NEW

Even though we have written anything lets update our manifest to tell Stonhearth that we’d like to mixin a file.

{
    "info" : {
          "name" : "r180mod",
          "version" : 1
    },
    "aliases" : {
          "my_mod_item" : "file(entities/my_mod_item/my_mod_item.json)"
    },
    "mixintos" : {
           "/stonehearth/jobs/carpenter/recipes/recipes.json" : 
              ["file(mixins/carpenter_recipes.json)"]
    }
}

mixintos are specified target : file to add

/stonehearth/jobs/carpenter/recipes/recipes.json - The file that holds all the carpenter recipes.
[“file(mixins/carpenter_recipes.json)”] - Our carpenter recipe file.

Lets set-up our carpenter_recipes.json file now. Match yours to this, make any adjustment for differences in names.

{
   "craftable_recipes" : {
      "furniture" : {
         "recipes" : {
            "my_mod_item" : {
               "recipe" : "file(/recipes/my_mod_item_recipe.json)"
            }
         }
      }
   }
}

There are many catergories for where to add items, I chose furniture. Take a look at
stonehearth\jobs\carpenter\recipes\recipes.json, if you like to use a different catagory, you can even add your own.

{
   "craftable_recipes" : {
      "$catagoryname" : {
         "ordinal" : 5, (5 and up I believe)
         "name" : "Display Name",
         "recipes" : {
            "my_mod_item" : {
               "recipe" : "file(/recipes/my_mod_item_recipe.json)"
            }
         }
      }
   }
}

With this out of the way, lets move on to our actual recipe. Open up my_mod_item_recipe.json

{
   "type":"recipe",

   "work_units"  : 3,
   "recipe_name" : "My Super Mod Item - Display Name",
   "description" : "Better than every item.",
   "flavor"      : "Stonehearthians will think this line of text",
   "portrait"    : "/r180mod/entities/my_mod_item/my_mod_item.png", 

   "ingredients": [
      {
         "uri" : "stonehearth:furniture:not_much_of_a_bed",
         "count" : 1
      },
      {
         "material" : "wood resource",
         "count" : 1
      }
  ],
  "produces": [
      {
         "item":"r180mod:my_mod_item"
      }
  ]
}

Lets break it down, I’ll go over only the ones that are not self explanitory.

“work_units” : 3 - How long to craft

“ingredients”: - This one’s a bit complicated, for each seperate ingredient you must specify { }'s, from here you have 2 options, require a specific item, or require that the item has a specific material tag.

“produces”: - specifies the return item from the crafting process

That should be good, final stretch :wink:

Step 4 - Entity_Forms and Iconic/Ghost


In our manifest’s aliases we specified
"my_mod_item" : "file(entities/my_mod_item/my_mod_item.json)"

Go ahead and create that file, along with it create 2 other files,

my_mod_item_iconic.json
my_mod_item_ghost.json

Our mod file structure so far

- r180mod
  ----manifest.json
  ----entities
      ----my_mod_item
          ----my_mod_item.qb
          ----my_mod_item_iconic.qb
          ----my_mod_item.png
          ----my_mod_item.json - NEW
          ----my_mod_item_iconic.json - NEW
          ----my_mod_item_ghost.json - NEW
  ----mixins
      ----carpenter_recipes.json
  ----recipes
      ----my_mod_item_recipe.json

For anything below rememeber to replace filenames/paths to match you own.
For my_mod_item.json

{
   "type" : "entity",
   "mixins" : "file(my_mod_item_ghost.json)",

   "components": {
      "stonehearth:entity_forms" : {
         "iconic_form" : "file(my_mod_item_iconic.json)",
         "ghost_form" : "file(my_mod_item_ghost.json)",
         "placeable_on_ground" : true
      },
      "region_collision_shape": {
          "region": [
            {
               "min" : { "x" : -0.5, "y" : 0, "z" : -0.5 },
               "max" : { "x" :  1.5, "y" : 1, "z" :  1.5 }
            }
         ]
      }
   },
   "entity_data" : {
      "stonehearth:net_worth" : {
         "value_in_gold" : 30,
         "rarity" : "common",
         "shop_info" : {
            "buyable" : true,   
            "sellable" : true,
            "shopkeeper_level" : 1,
            "shopkeeper_type" : "caravan"
         }
      }
   }
}

Things to note, (if you need more specific info feel free to ask)

“placeable_on_ground” - There is also “placeable_on_walls”

“entity_data” - I am completely guessing, is used by other entities, ie a bed specifies “stonehearth:bed” : {}, allows other entites, to know it’s a bed.

“region_collision_shape”: - bounds of the object, I am guessing again but I think they are based on Stonehearth cube size which is 1 voxel. Hard to test, can’t micro.

Next up my_mod_item_ghost.json

{
   "type": "entity",

   "components": {
      "model_variants": {
         "default": {
            "models": [
               "file(my_mod_item.qb)"
            ]
         }
      },
      "unit_info": {
         "name": "My Super Mod Item",
         "description": "Whoo wa weee wa",
         "icon" : "file(my_mod_item.png)"
      },
      "stonehearth:material" : {
         "tags" : "wood furniture crafted"
      },
      "mob" : {
         "model_origin" : { "x": 0, "y": 0, "z": 0 },
         "region_origin" : { "x": 0.5, "y": 0, "z": 0.5 }
      }
   }
}

Notes

“tags :” - Change this to what ever you want
"model_origin" : - Used to create a display offset for the model, I haven’t test but thats what it should be. “region_origin” : - I haven’t test but I would guess a position offset, ie .5 half the width of a StoneHearth cube size, which is 1 voxel. ie x .5, y 0, z .5 , centered in the xz plane.

Finally my_mod_item_iconic.json

{
   "mixins": "stonehearth:mixins:item_properties",
   "type": "entity",
   "components": {
      "item" : {
         "category" : "furniture"
      },
      "model_variants": {
         "default": {
            "models": [
               "file(my_mod_item.qb)"
            ]
         }
      },
      "mob" : {
         "model_origin" : { "x": -0.05, "y": 0, "z": 0.05 }
      }
   }
}

Notes

“category” : “furniture” - I would guess this is used for sorting in stock piles

Debugging Problems


We are only human, so we are bound to make mistakes. Here’s some tips

Check the log

C:\Program Files (x86)\Steam\SteamApps\common\Stonehearth\stonehearth.log
it can detail whats going wrong, other’s can help you if you can’t understand it.

Check your json file, very very common mistakes happen here, ie a " , " where it does not belong

Can verify any errors in you json files

Typos and Wrong Paths
Keep naming conventions,

“comfy_bed_red”
“comfy_bed_blue”
“comfy_bed_green”

Don’t do this

“comfy_red_bed”
“bed_comfy_blue”
“green_bed_comfy”

Name things consistently, this helps identify typos and remember what you have named things.
Goes without saying, but I figured I was mentioning common problems, this is one you will likely run into.

Trolled by load game

I have no idea what causes this, but it is very very frustrating. My only guess is that items ui info is somehow reliant on some of your save, that if you change an items display name, the save fails to recognize that the paths have changed, and just amuses it’s the same, causing to fail to find the path. Start a new game to make sure you’ve really done something wrong.

Ask the community, people are always around and willing to help.

Best of luck

19 Likes