User Tools

Site Tools


tutorial:jigsaw

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:jigsaw [2020/05/06 19:45]
ffrann fixed tip size
tutorial:jigsaw [2020/08/07 00:10] (current)
emmanuelmess Corrected first heading
Line 2: Line 2:
 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.  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. 
  
-A repository with finished code can be found [[https://​github.com/​Draylar/​jigsaw-example-mod|here]].+A repository with finished code can be found [[https://​github.com/​Draylar/​jigsaw-example-mod|here ​for 1.14]], [[https://​github.com/​Draylar/​jigsaw-example-mod/​tree/​1.15|here for 1.15]], [[https://​github.com/​EmmanuelMess/​jigsaw-example-mod/​tree/​1.16.1|here for 1.16]]  
 + 
 +===== Creating a StructureFeature (for 1.15) =====
  
-==== Creating a StructureFeature ==== 
 A ''​StructureFeature''​ is an advanced ''​Feature'':​ it keeps track of its location and bounds, and also has the ability to generate itself from a structure file((While you can generate your StructureFeature from a ''​.nbt''​ file, most vanilla StructureFeatures simply override the ''​generate''​ method inside their given Piece class.)). If it helps, you can think of it as a ''​Structure''​ + ''​Feature''​. We'll need to create one for our jigsaw generated structure. To start, create a class that extends ''​StructureFeature<​DefaultFeatureConfig>''​((AbstractTempleFeature is another option. It automatically spaces out the structures similar to the existing temples-- this logic is also used by villages.)). Feature naming convention is "​structure name" + "​Feature";​ a few vanilla examples are ''​EndCityFeature'',​ ''​OceanRuinFeature'',​ and ''​VillageFeature''​. A ''​StructureFeature''​ is an advanced ''​Feature'':​ it keeps track of its location and bounds, and also has the ability to generate itself from a structure file((While you can generate your StructureFeature from a ''​.nbt''​ file, most vanilla StructureFeatures simply override the ''​generate''​ method inside their given Piece class.)). If it helps, you can think of it as a ''​Structure''​ + ''​Feature''​. We'll need to create one for our jigsaw generated structure. To start, create a class that extends ''​StructureFeature<​DefaultFeatureConfig>''​((AbstractTempleFeature is another option. It automatically spaces out the structures similar to the existing temples-- this logic is also used by villages.)). Feature naming convention is "​structure name" + "​Feature";​ a few vanilla examples are ''​EndCityFeature'',​ ''​OceanRuinFeature'',​ and ''​VillageFeature''​.
  
Line 117: Line 118:
  * turns into  * turns into
  
-{{https://​i.imgur.com/​owaJ0k2.png|Blank Jigsaw}}+{{ https://​i.imgur.com/​owaJ0k2.png?​nolink&​600 ​|Blank Jigsaw}}
  
 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!"​ The target pools of 2 jigsaws do not have to match: the requestor gets to decide who they select from. It is **not** defining what type //the given// jigsaw block is, but rather what type should be on the //other side//. 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!"​ The target pools of 2 jigsaws do not have to match: the requestor gets to decide who they select from. It is **not** defining what type //the given// jigsaw block is, but rather what type should be on the //other side//.
Line 127: Line 128:
 Here's an example implementation:​ the given jigsaw will draw from the //​tutorial:​my_pool//​ structure pool, looks for any jigsaws with the //​tutorial:​any//​ type, and turns into cobblestone when it's done. Here's an example implementation:​ the given jigsaw will draw from the //​tutorial:​my_pool//​ structure pool, looks for any jigsaws with the //​tutorial:​any//​ type, and turns into cobblestone when it's done.
  
-{{https://​i.imgur.com/​f9tP2sv.png|Example Finished Jigsaw}}+{{ https://​i.imgur.com/​f9tP2sv.png?​nolink&​600 ​|Example Finished Jigsaw}}
  
 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:
-{{https://​i.imgur.com/​dVFADy8.png|Initial Squares}}+ 
 +{{ https://​i.imgur.com/​dVFADy8.png?​nolink&​400 ​|Initial Squares}}
  
 This jigsaw will ask for any other jigsaw that: This jigsaw will ask for any other jigsaw that:
Line 138: 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:
-{{https://​i.imgur.com/​31LAORw.png|Finalized Initial Squares}}+ 
 +{{ https://​i.imgur.com/​31LAORw.png?​nolink&​400 ​|Finalized Initial Squares}}
  
 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.
-{{https://​i.imgur.com/​OngxweJ.png|Colored Squares}}+ 
 +{{ https://​i.imgur.com/​OngxweJ.png?​nolink&​400 ​|Colored Squares}}
  
 We now have 6 saved ''​.nbt''​ files. These can be found in our world save folder under ''​generated'':​ We now have 6 saved ''​.nbt''​ files. These can be found in our world save folder under ''​generated'':​
-{{https://​i.imgur.com/​ZKIoZT9.png|Saved NBT files}}+ 
 +{{ https://​i.imgur.com/​ZKIoZT9.png?​nolink&​400 ​|Saved NBT files}}
  
 For usage, we'll move these to ''​resources/​data/​tutorial/​structures'',​ where "​tutorial"​ is your modid: For usage, we'll move these to ''​resources/​data/​tutorial/​structures'',​ where "​tutorial"​ is your modid:
-{{https://​i.imgur.com/​kaiy84U.png|Moved NBT files}}+ 
 +{{ https://​i.imgur.com/​kaiy84U.png?​nolink&​400 ​|Moved NBT files}}
  
 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 263: Line 269:
 === Finished! === === 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. 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://​i.imgur.com/​qndZzZu.png|Finalized}}+ 
 +{{ https://​i.imgur.com/​qndZzZu.png?​nolink&​600 ​|Finalized}}
 === Jigsaw Tips === === 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. ​ 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.  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/jigsaw.1588794320.txt.gz · Last modified: 2020/05/06 19:45 by ffrann