tutorial:structures
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:structures [2019/02/16 20:56] – ↷ Page moved and renamed from features to tutorial:structures asie | tutorial:structures [2019/02/16 20:58] – asie | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | **An example repo containing | + | ====== Generating Structures ====== |
+ | |||
+ | ===== Features ===== | ||
+ | |||
+ | All code used in this tutorial | ||
+ | |||
+ | ==== Introduction ==== | ||
We’re going to look at registering and placing structures in your world. | We’re going to look at registering and placing structures in your world. | ||
Line 7: | Line 13: | ||
You are going to need a Feature and Generator for the most basic structure. The feature handles the process of registering the structure and loading it in when the world is generating-- it answers questions such as ‘should I spawn here?’ and ‘what is my name?’ The generator handles the placement of blocks or loading in a structure file if you choose to do so. | You are going to need a Feature and Generator for the most basic structure. The feature handles the process of registering the structure and loading it in when the world is generating-- it answers questions such as ‘should I spawn here?’ and ‘what is my name?’ The generator handles the placement of blocks or loading in a structure file if you choose to do so. | ||
- | To create a basic feature, we recommend creating a class that extends AbstractTempleFeature< | + | ==== Creating a Feature ==== |
+ | |||
+ | To create a basic feature, we recommend creating a class that extends AbstractTempleFeature< | ||
* shouldStartAt: | * shouldStartAt: | ||
Line 39: | Line 47: | ||
This is called when the world attempts to spawn in a new structure, and is the gap between your Feature and Generator. The reference to the variable in your main class doesn' | This is called when the world attempts to spawn in a new structure, and is the gap between your Feature and Generator. The reference to the variable in your main class doesn' | ||
- | This is where structure files and generating straight from a generate method part ways. If you want, you can simply override generate in your Feature class and use setBlockState to place blocks directly in the world. This is a valid option and was popular pre-1.13, but structure files are simply more powerful at this point and are highly recommended. | + | This is where structure files and generating straight from a generate method part ways. There are two ways to go about this: |
+ | |||
+ | * If you want, you can simply override generate in your Feature class and use setBlockState to place blocks directly in the world. This is a valid option and was popular pre-1.13. | ||
+ | * Use structure files and a Generator. These are rather | ||
+ | |||
+ | ==== Creating a Generator ==== | ||
As you have probably noticed, we need to create a generator. We'll name it MyGenerator, | As you have probably noticed, we need to create a generator. We'll name it MyGenerator, | ||
* An Identifier that points to your structure file; use " | * An Identifier that points to your structure file; use " | ||
- | * Some sort of setup method-- addParts is a good name: | + | * Some sort of setup method - addParts is a good name: |
public static void addParts(StructureManager structureManager_1, | public static void addParts(StructureManager structureManager_1, | ||
Line 121: | Line 134: | ||
In this case, we simply get the y position of the highest block in the middle of our chunk and generate the structure off that position. | In this case, we simply get the y position of the highest block in the middle of our chunk and generate the structure off that position. | ||
+ | ==== Registering Features ==== | ||
The last step is to register our features. We're going to need to register: | The last step is to register our features. We're going to need to register: |
tutorial/structures.txt · Last modified: 2022/11/05 12:06 by jab125