How can I implement trees in the World Generation?


#1

I am currently attempting to make a mod adding trees to a custom biome. I have the models for the trees done and have done the coding aside from world generation. I tried looking at other people’s posts with the same problem however I wasn’t able to come to a conclusion as to how to solve it. What are the steps I need to take to implement a custom type of tree into the world gen?


#2

You’ll want to look in the data/biome folder for information on world gen. In order to make your own biome you’ll have to make a new .Json for the biome, put in in the index, then add pictures in the images folder.

To simply add a tree in to an existing biome, for example temperate, you:
1 Copy the whole temperate.json, and add in to it at about lines 154 to 210 info about your new tree.
2 In the manifest for your mod, you’ll need to overwrite the stonehearth temperate.json with yours.
3 Then, you need to make an entity folder, followed by a “tree” folder. You can then add a new folder containing your tree, which contains folders about any variations of your tree, if you want it to grow. Finally, you can add the models and more code there.

If this doesnt clear it up, Feel free to say so.


#3

If you’re adding your own custom biome, don’t override the temperate. Do a mixinto to the stonehearth/data/biome/index.json and add your biome there. You can copy the temperate or desert and substitute the trees with your own trees on them (where the aliases appear).


#4

Right. The 1-3 steps were to simply add trees to an existing biome.


#5

Thank you for the help, admittedly I have already done the steps for the biome creation (with mixinto) and I added the entity with the folder and the lines for the tree in my biome. The issue that I am having is that the game doesn’t load the biome and outputs an error message as below:

Unknown JSON literal: 16}“additional_biomes:trees:fall_oak”:{“small”:0,“medium”:8,“large”:18,“ancient”:{“percentage”:10}

when trying to parse my biome .json. Thanks again in advance.


#6

Hmm, have you validated the biome in jsonlint.com ?


#7

I validated it on jsonlint.com and there was just a small error in a missing comma, thanks again for all the help! I feel dumb now.


#8

No problem :smile:
It’s better to talk with someone when you’re stuck.


#9

So I have ran into another problem, how do I completely remove stonehearth trees from generating in the biome? I tried removing all references in my custom biome but it creates an error upon world generation.


#10

Ugh, first of all, when touching the biome file, do only one or two changes between testing, because it’s easy to break it.

You can try replacing in the biome file all references of stonehearth trees with your trees as a first step.
The part that says:
"landscape": { "placement_table" : { "candyland:trees:candy_tree" : { "placement_type" : "single", "parameters" : { "ground_radius" : 2, "exclusion_radius" : 5 } },

should only contain your trees (in this case I used a custom tree for the example).

Then, in the “trees” : { “sizes” section below, make sure that it says “small” and “large” with some values even if you don’t have those sizes for your trees (in the Stonehearth manifest, trees aliases end with “:large” or “:small” but you don’t need to do it in your mod if your trees have just one size).

In the “weights” section, use your custom trees aliases.


#11

I followed your instructions as you wrote them, I had tried it before but I realize it crashed due to myself setting the small value to something other than 0. I left it at 0, and removed all references of the other trees and now it works as I wanted. Thanks a ton for all the help!


#12

Yeah, I forgot to mention it. Glad you figured it out! :wink: