tutorial:structures
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:structures [2020/09/11 06:47] – 1.16.2 siglong | tutorial:structures [2020/11/02 14:17] – Use Biome Modification API in Fabric API siglong | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
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 7: | ||
The feature handles the process of registering the structure and loading it in when the world is generating. | The feature handles the process of registering the structure and loading it in when the world is generating. | ||
The generator handles the placement of blocks or loading in a structure file if you choose to do so. | The generator handles the placement of blocks or loading in a structure file if you choose to do so. | ||
+ | |||
+ | Note that this tutorial depends on [[https:// | ||
+ | If the API doesn' | ||
===== Creating a Feature ===== | ===== Creating a Feature ===== | ||
Line 57: | Line 60: | ||
In this tutorial, we'll use a structure file. | In this tutorial, we'll use a structure file. | ||
It doesn' | It doesn' | ||
- | * An Identifier | + | * An identifier |
* Some sort of setup method - '' | * Some sort of setup method - '' | ||
Line 103: | Line 106: | ||
private void initializeStructureData(StructureManager structureManager) { | private void initializeStructureData(StructureManager structureManager) { | ||
Structure structure = structureManager.getStructureOrBlank(this.template); | Structure structure = structureManager.getStructureOrBlank(this.template); | ||
- | StructurePlacementData placementData = (new StructurePlacementData()).setRotation(this.rotation).setMirror(BlockMirror.NONE) | + | StructurePlacementData placementData = (new StructurePlacementData()) |
- | .addProcessor(BlockIgnoreStructureProcessor.IGNORE_STRUCTURE_BLOCKS); | + | |
+ | | ||
+ | .addProcessor(BlockIgnoreStructureProcessor.IGNORE_STRUCTURE_BLOCKS); | ||
this.setStructureData(structure, | this.setStructureData(structure, | ||
} | } | ||
Line 130: | Line 135: | ||
* structure | * structure | ||
- | * pieces | + | * piece |
* configured structure | * configured structure | ||
Line 137: | Line 142: | ||
public static final StructurePieceType MY_PIECE = MyGenerator.MyPiece:: | public static final StructurePieceType MY_PIECE = MyGenerator.MyPiece:: | ||
private static final StructureFeature< | private static final StructureFeature< | ||
- | | + | |
@Override | @Override | ||
Line 148: | Line 153: | ||
.register(); | .register(); | ||
- | | + | |
- | MY_CONFIGURED); | + | |
+ | | ||
} | } | ||
} | } | ||
</ | </ | ||
- | ===== Adding a configured feature to a biome ===== | + | ===== Adding a configured feature to biomes |
- | Vanilla features generated in the plain biomes are listed in '' | + | In this tutorial, we add our structure to all biomes. |
- | We modify | + | |
<code java> | <code java> | ||
- | @Mixin(DefaultBiomeFeatures.class) | + | public class ExampleMod implements ModInitializer |
- | public class DefaultBiomeFeaturesMixin | + | [...] |
- | @Inject(method = " | + | |
- | | + | @Override |
- | | + | |
+ | | ||
+ | |||
+ | BiomeModifications.addStructure(BiomeSelectors.all(), myConfigured); | ||
} | } | ||
} | } | ||
- | |||
</ | </ | ||
===== Result ===== | ===== Result ===== | ||
- | You should be met with igloos | + | You should be met with igloos. |
You can use below command to find your structure in the world. | You can use below command to find your structure in the world. | ||
tutorial/structures.txt · Last modified: 2022/11/05 12:06 by jab125