Saving Your Schematic
To make a custom building generate naturally in your world, you first need a saved .nbt schematic file (such as one saved using a vanilla Structure Block). Move this .nbt file into your datapack's structures/ directory so the game can locate it.
Creating the Structure Spawner File
Next, navigate to the structure_spawners/ folder inside your datapack and create a new configuration file named <structure name>.json. Inside this JSON file, include the required template, placement, and averageSpacing entries.
Under the template section, configure how the schematic loads:
- Set
"type": "single"to tell the spawner to load one standalone.nbtfile from yourstructures/folder. - Set
"id"to the location of your file using the standardnamespace:pathformat. - If you are generating something like a path or road that needs to match the slope of the ground, add
"followTerrain": trueinside thetemplateblock. For normal buildings with flat floors, leavefollowTerrainat its default offalse.
Finally, set "averageSpacing" to an integer representing the average horizontal distance in chunks between spawn attempts, and fill in your required "placement" rules. Load your datapack into a world to begin finding your structure.