Skip to content

Building Basic Structures

George Paton edited this page Nov 21, 2025 · 2 revisions

Basic structures, as in, ones that don't generate using any jigsaw pieces and are just one big structure- are very easy to implement within NBTStructureLib. All you need is a structure wand and a structure you've built.

Preparing your structure

Before we save our structure, we'll need to add blocks that indicate to the structure generation system to place certain blocks. The structure system is designed with developer intent in mind, in that only blocks explicitly placed will spawn in the structure.

In pursuit of this, two placeholder blocks are available for you to place in your structures:

  • Structure Air Block - This block will replace any block it finds with air, underground structures will need air placed or else they'll be vitrified with rock. Smart placement of air can create cool effects (say, placing air everywhere except the bottom-most blocks to make a nuclear sub placed in water be half flooded).
  • Structure Loot Block - Normal chests will always spawn with exactly the items placed in them, this block will instead randomly generate its contents from GenChestHook categories (which can be added to). The arrow indicates the facing direction of the inventory block when generated. These blocks can be set to generate any type of single block inventory (chests, etc) by using the desired block on them directly.

Saving your structure

Next, we need to create our structure .nbt. In order to create that, grab a structure wand, and click two corners that enclose your entire build. If you have blocks inside your build that you don't want (say, you build in a Redstone Ready superflat world and don't want to include sandstone), you can crouch click that block to blacklist it from saving.

A useful tip for saving the bounds of your structure is to pick a block that you definitely won't be using within the structure (like say, gold blocks), adding that to the blacklist, and using those blocks to mark the corners of your structure. Then for any changes you know exactly where to click to get the exact same bounds each time.

Once you've saved your structure, it'll be saved in the same directory as your screenshots/ folder, under structures/.

Adding your structure to your mod

Now that you have your structure .nbt, you must define how it spawns in your mod. You'll want some location to load in these structures (Note that this loads on servers, so it should not be done where you load models/textures). Your loading should look something like this:

public static final NBTStructure my_structure = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/my_structure.nbt"));

Now that you have a structure loading in, you'll want to indicate to the world generator to spawn it into specifc dimensions/biomes. The example below will spawn my_structure in dimension 0 (Overworld). All fields here are set to their defaults except for canSpawn and structure. Your spawning defintion should look like the below:

NBTGeneration.registerStructure(0, new SpawnCondition() {{

	// This is the structure to spawn, the optional number at the end defines the y-offset of the piece.
	// If you had, say, a concrete floor, you'd put in -1 to sink the floor into the ground.
	structure = new JigsawPiece("my_structure", StructureManager.my_structure, 0) {{

		// If true, moves every single column to the terrain
		// (terrain conforming natural structures, or digging out trenches if negative and has air blocks)
		conformToTerrain = false;

		// Defines block replacements based on a BlockSelector, which can randomly pick new blocks
		blockTable = new HashMap<Block, BlockSelector>() {{
			put(Blocks.wool, new RandomWoolColor()); // example
		}};

	}};

	// This defines what biomes the structure can spawn in, any biome fields can be used, like temperature or height.
	canSpawn = biome -> biome == BiomeGenBase.deepOcean; // example

	// How likely this structure is to spawn compared to others, higher = more likely
	spawnWeight = 1;

	// Height modifiers, will clamp height that the start generates at, allowing for:
	//  * Submarines that must spawn under the ocean surface
	//  * Bunkers that sit underneath the ground
	//  * Airships that must float in the sky
	maxHeight = 1;
	minHeight = 128;

}});

Now your structure should spawn in the biomes you've selected with rarity defined by spawn weight.

Adding Subtle Variation

A way of adding simple variation to your structures to make them somewhat visually distinct and randomized is to use BlockSelectors, these can take a specified block and randomly turn it into another block. For example, you can turn concrete bricks into their cracked and mossy variants. See the above code definitions to add these.

Conforming to Terrain

If a structure is defined as conforming to terrain, every single column in the structure file will be moved such that the starting y-level (before offset is applied) is moved to the highest generated non-liquid block in the world.

Clone this wiki locally