tutorial:1.15:jigsaw
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:jigsaw [2019/10/20 22:29] – fix type stuff draylar | tutorial:1.15:jigsaw [2020/08/14 18:10] – emmanuelmess | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Jigsaws! | + | ====== |
+ | Jigsaws are good for advanced structures such as dungeons & villages, and allow you to spend more time on actually building content vs. messing with procedural generation code. | ||
- | Starting: | + | A repository with finished code can be found [[https:// |
- | - StructureFeatureclass | + | |
- | - StructureStart class | + | |
- | - Piece class | + | |
- | `Feature` is essentially | + | ===== Creating |
- | - trees | + | |
- | - rocks | + | |
- | - dungeons | + | |
- | - underground ores | + | |
- | ==== Creating a StructureFeature ==== | + | A '' |
- | A '' | + | |
//Note: while Feature is the proper name for something generated in the world, we'll refer to our addition as a Structure. This is to distinguish between a StructureFeature and a standard Feature.// | //Note: while Feature is the proper name for something generated in the world, we'll refer to our addition as a Structure. This is to distinguish between a StructureFeature and a standard Feature.// | ||
- | We'll keep the constructor as-is. The `Function< | + | We'll keep the constructor as-is. The '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 125: | Line 118: | ||
* turns into | * turns into | ||
- | [jigsaw_blank] | + | {{ https:// |
When thinking about this as a puzzle, the target pool is the group of puzzle pieces you can search through. If you have a total of 10 pieces, one target pool may have 7 of the total pieces. This field is how a jigsaw specifies, "Hi, I'd like a piece from group B to connect to me!" In the case of a village, this may be a road saying, "Give me a house!" | When thinking about this as a puzzle, the target pool is the group of puzzle pieces you can search through. If you have a total of 10 pieces, one target pool may have 7 of the total pieces. This field is how a jigsaw specifies, "Hi, I'd like a piece from group B to connect to me!" In the case of a village, this may be a road saying, "Give me a house!" | ||
Line 135: | Line 128: | ||
Here's an example implementation: | Here's an example implementation: | ||
- | [jigsaw_finished] | + | {{ https:// |
Our finalized structure will consist of multiple colored squares connecting to each other. It will have a white or a black square in the center, and orange, magenta, light blue, and lime squares branching off on the sides randomly. Here is the setup of our 2 initial squares: | Our finalized structure will consist of multiple colored squares connecting to each other. It will have a white or a black square in the center, and orange, magenta, light blue, and lime squares branching off on the sides randomly. Here is the setup of our 2 initial squares: | ||
- | [pre] | + | |
+ | {{ https:// | ||
This jigsaw will ask for any other jigsaw that: | This jigsaw will ask for any other jigsaw that: | ||
Line 146: | Line 140: | ||
For demo purposes, we've made 2 starting platforms: one is white, and one is black. The only difference is what they turn into. We'll save these as structure files using structure blocks: | For demo purposes, we've made 2 starting platforms: one is white, and one is black. The only difference is what they turn into. We'll save these as structure files using structure blocks: | ||
- | [bwpost] | + | |
+ | {{ https:// | ||
For our randomized edge platforms, we've made 4 extra squares of different colors. Again, despite being used for a different purpose, the jigsaw construction is //the same// aside from the "turns into" field. | For our randomized edge platforms, we've made 4 extra squares of different colors. Again, despite being used for a different purpose, the jigsaw construction is //the same// aside from the "turns into" field. | ||
- | [post] | + | |
+ | {{ https:// | ||
We now have 6 saved '' | We now have 6 saved '' | ||
- | [location] | + | |
+ | {{ https:// | ||
For usage, we'll move these to '' | For usage, we'll move these to '' | ||
- | [destination] | + | |
+ | {{ https:// | ||
The setup is complete! We now have 6 total squares. Let's briefly recap the goal: | The setup is complete! We now have 6 total squares. Let's briefly recap the goal: | ||
Line 249: | Line 248: | ||
Registry.STRUCTURE_FEATURE, | Registry.STRUCTURE_FEATURE, | ||
new Identifier(" | new Identifier(" | ||
- | new ExampleFeature(DefaultFeatureConfig:: | + | EXAMPLE_FEATURE |
); | ); | ||
Line 263: | Line 262: | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Registry.BIOME.forEach(biome -> { | Registry.BIOME.forEach(biome -> { | ||
- | biome.addFeature(GenerationStep.Feature.RAW_GENERATION, | + | biome.addFeature(GenerationStep.Feature.RAW_GENERATION, |
- | biome.addStructureFeature(EXAMPLE_FEATURE, new DefaultFeatureConfig()); | + | biome.addStructureFeature(EXAMPLE_FEATURE.configure(new DefaultFeatureConfig())); |
}); | }); | ||
</ | </ | ||
+ | |||
+ | === Finished! === | ||
+ | As you can see, we have a single white square in the center, with boxes going off the edges. Note that the radius in this screenshot was increased to 14 instead of the 7 used in the tutorial. | ||
+ | |||
+ | {{ https:// | ||
+ | === Jigsaw Tips === | ||
+ | Ideally, you do not want structure pieces to be bigger than 32x32x32, so breaking them into chunk-sized pieces is the best option. | ||
+ | You cannot generate other structure pieces of the same pool through jigsaws. So, if you have a piece in pool A and you try to generate another piece, you will have to have another pool. |
tutorial/1.15/jigsaw.txt · Last modified: 2021/12/28 19:44 by banana