I have seen this quite a few times in the last weeks in the Dev section. So I thought it would be nice to show you guys how I did it, what I have learned, and a good place to start.
First - A good place to start, as I have mentioned to many others, and also where I first learned how to do this, is by following wuppy21's guide for structure generation. His guide is for 1.3.2 but still works very well, with a few minor fixes here and there which I will explain later. You will also need a few tools, as mentioned in wuppy21's thread, or you can do this just by coding it out on paper and trying it out ( I dont recommend this for any beginner, much harder than doing it the easy way which may take longer depending on how big your structure is.
Second - You will need some tools, as mentioned in the tutorial by wuppy21. You will need a schematic to java converter and also MCEdit. Some of you may know also that it is possible to, with forge and also modloader, to import schematic files directly into the world. While this is possible, I personally do not like this way because of how some schematics may have errors, or are old and have some misplaced blocks that will produce strange errors, or have custom blocks left over from a mod that was used in creating the schematic, or any other number of issues that can arise.
Schematic Converter #2 - Not recommended, not meta support as well as only provides block ID, not the block names.
Schematic Converter #3 - This is a new tool shown to me by Bendonnelly1. Not quite sure of how well this will work I have not tested it myself yet, but seems like it will be a much better tool for larger schematics.
MCEdit - we should have all heard of this tool by now
Information on using these tools will be posted later, for now you can view the pages for detailed information or watch the videos by wuppy21 using the link above.
Getting Started - The Basics
Once we have the tools above we must get some schematics, you may ask how do we do this. Well, first we could create a new world and build the structure we want, the way we want it, however because the convert tool is for 1.3.2, you should limit you block choices to blocks from that version and below. Dont worry we can change them later. Now that you have your structure built, load or run MCEdit and load your world you just created and locate your structure, select your structure and export as a schematic. Now we can use our converter to convert the schematic to a java file. Once we have done that we will have a file that looks like this....
/*
*** MADE BY MITHION'S .SCHEMATIC TO JAVA CONVERTING TOOL v1.6 ***
*/
package net.minecraft.src;
import java.util.Random;
public class academy1 extends WorldGenerator
{
public academy1() { }
public boolean generate(World world, Random rand, int i, int j, int k) {
world.setBlock(i + 0, j + 0, k + 0, Block.dirt.blockID);
world.setBlock(i + 0, j + 0, k + 1, Block.dirt.blockID);
world.setBlock(i + 0, j + 0, k + 2, Block.dirt.blockID);
world.setBlock(i + 0, j + 0, k + 3, Block.dirt.blockID);
world.setBlock(i + 0, j + 0, k + 4, Block.dirt.blockID);
return true;
}
}
I am sure yours will have a lot more code in it, this is just an example. However you will need to make sure you scan your code because the new 1.5.x changed some things in the way ore, trees, plants, and structures are generated. The above will work just fine as the dirt block has no metadata or notifications to worry about. The following will not work with out having some changes made to the code....
This is the way I have it in my mod now and it works just fine, there may be another way to do this, but this is what works for me. Another thing to be on the watch for is errors in the conversion. One such error you will need to know to watch for as it will not always show the error is negative integers or block ID's. A negative value in the block ID will crash the game with a null exception error, and will point to your structure class. They may look like this....
world.setBlock(x, y, z, -122);
Easiest way to fix these is to first comment them all out and get the structure generating first. Then you can go back and substitute them for the correct blocks if you know what they are, or just change them to a block type that is not in the structure, good ones to use that stand out are block diamond, block gold, haybale or anything else that stands out and is not already a part of the structure.
Now, you may be thinking, but wait, Microjunk, you havent told us how to generate the structure. Okay, there are several ways to do this as well. Structures can be generated using the same methods as Ore, Trees, Plants, or anything else that has to be generated in the world. They can also be generated using commands if you so choose to set them up that way or by block activation. For typical world gen like flowers and trees, you will need to add one line of code to your mod class and create one new class like this.
The above goes in your mod class, and the following is the new class
import net.minecraft.world.chunk.IChunkProvider;
import cpw.mods.fml.common.IWorldGenerator;
public class WorldGeneratorYourStructure implements IWorldGenerator
{
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
switch (world.provider.dimensionId)
{
case -1: generateNether(world, random, chunkX*16, chunkZ*16);
case 0: generateSurface(world, random, chunkX*16, chunkZ*16);
}
}
private void generateSurface(World world, Random rand, int chunkX, int chunkZ)
{
WorldGeneratorYourStructure tree = new WorldGeneratorYourStructure();
for(int x = 0;x<2;x++)
{
int i = chunkX + rand.nextInt(16);
int k = chunkZ + rand.nextInt(16);
int j = world.getHeightValue(i, k);
tree.generate(world, rand, i, j, k);
}
}
private void generateNether(World world, Random random, int blockX, int blockZ)
{
}
}
There are other ways to do this, but this is the most common way. If you want them to generate using commands, you will need a command tutorial for that, as I dont know. You can also do this with onBlockActivated in your block class like this....
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par2, float par3, float par4, float par5)
{
world.setBlock(i, j, k, 0);
this.gen(world, rand, i, j, k);
}
return true;
}
public void gen(World world, Random rand, int i, int j, int k)
{
world.setBlock(i, j, k, 0);
WorldGenYourStructure gen = new WorldGenYourStructure();
if (!gen.generate(world, rand, i, j, k))
{
world.setBlock(i, j, k, this.blockID);
}
}
The above will set your block to zero(remove the block) and generate your structure. Now, your structure may not generate in front of you, but there are ways of fixing this, and will be covered in another tutorial for advanced generation.
More will be added to this later as I find more to add, as I said this is for beginners and this is pretty basic stuff....Good Luck and have fun and happy generating....
For a much more advanced way of of generating your structures, adding in proper rotation, placement, and positioning, have a look at this post here by coolAlias. If this link does not work, it is post number 7 on this page.
Another tutorial is in the works for generating structures from block activation that will set the structure directly in front of the player no matter which way they are facing and also for structure rotation. There are some things being worked out right now that will make this possible with WorldGenerator files so we will no longer have to use schematics in mods.
They will also be able to be added from anything that you can activate - you just need access to the world and the structure library Ideally, this will still be compatible with schematics and things like MCEdit... maybe you can help out with how to convert from those into an array?
Just as soon as we get that working, I was going to add that in the advanced tut. I want to make sure I can do them myself as well, Id really hate to have you do them all for me, what would I learn from that. And, you're right, anything you can activate, like right clicking an item, block, or other just so long as it can access the library will do just fine. I just wanted something basic to get them started, and then get more advanced once that portion is complete. I will also add in how to load up chests with loot within a structure too.
Bookmarked for reference and I will also add it to the list of tools. After as many google searches I feel I got scroogled out of this one. I did not know about this at all. Now if we can just get one that turns them into component pieces for adding to villages on world generation.
NOTE: For the full description of this mod / tool, visit my mod page here or visit my github page.
Alright, the moment you've all been waiting for!!!! Okay, maybe just Micro's been waiting for it, but here it is
I've created a standalone tool that allows you to rotate, offset and change the default orientation of your custom structures when you generate them in the world, or even change it on the fly between adding structures with a block or item. The only caveat is your structure must be stored in an array format, specifically an int[][][][]
Don't worry, I've provided an example and a template, and there might be some handy tools around somewhere to convert from schematics / mcedit to code or array form. If not, it is a lot of work to set up, but no more than writing all those lines in the WorldGen file and it pays you back with a lot of flexibility.
There is only 1 necessary file to include in your mods if you want to use my tool, called WorldGenStructure, and another file called StructureArrays that will show you how to set up your structures for use with my tool, though it isn't necessary to include in your mod.
I've also included a standalone mini-mod that demonstrates the functionality of my tool without you having to set anything up. Read the readme file on github for more information about it.
Here are some screen shots from testing:
A row of houses generated without me taking a single step.
A structure correctly removed after generated - note that blocks that can drop as items often do:
An incorrectly removed structure - I spawned it on the block where the stairs go, so when I tried to remove it my 'y' position was one block higher due to the stairs:
A pic that doesn't do justice the massively sprawling hutropolis I spawned making this:
I don't know that I'll be writing a tutorial on it anytime soon, but there are copious notes throughout the code, so it's kind of a tutorial already.
If you're needing help understanding how to set up your structure array, here's an explanation of how arrays work that may help:
You all know what an array is, but did you know that each value in an array can store another array?
Make a single array that stores ints, our y values:
int[] y = {5, 10, 2, 39};
It has 4 values stored at locations y[0],y[1], etc.
But we can make y[0] not store a value, but store an array of integers instead:
int[][] y = { { 5 }, {10}, {2}, {39} };
Note we have the same values, but now they are stored at:
y[0][0] = 5, y[1][0] = 10, y[2][0] = 2, etc.
Adding more values:
int[][] y = { { 5,10,2,39 }, {7,3,16 } };
Now we've made it so y[0] stores the array [0] = 5, [1] = 10, etc. and
y[1] stores the array [0] = 7, [1] = 3, etc.
Note that arrays defined this way (i.e. with { } ) are static and can store different numbers of variables in each array - they don't have to have the same length.
Thinking in terms of structures, then, we need an array to store all of our y values, and for each y value we must store an array of x values, and for each x value we must store an array of z values, giving us a 3D matrix:
int[][][] 3d = { {
{ 0,1,2 }, { 0,1,2 },{ 0,1,2 } }, // y = 0, 3 x values that each store z = 0, 1, 2
{ 0,1,2 }, { 0,1,2 },{ 0,1,2 } }, // y = 1, 3 x values that each store z = 0, 1, 2
{ 0,1,2 }, { 0,1,2 },{ 0,1,2 } } }; // y = 2, 3 x values that each store z = 0, 1, 2
However, we need to store more than a single int at our location x,y,z, because we need block ID, metadata and possibly a flag, so each of our z values must also store an array.
Thus the 4 dimensional array used for storing structures.
Wow, simply WOW.....Just amazing work coolAlias. And as you pointed out it will be some work to get my mod working just right and as close to perfect as I can get. But the pay off should be 10 fold. I will be taking some time to review all the code and notes you have created and try out the demo tomorrow. This will take a bit, I have some 60 structures give or take, but the end result will be amazing....
Thank you ever so much for this, your time and effort is absolutely worth every bit of what this will do....
Heh, I don't envy you rewriting all those structures! Just the simple NPC Hut took long enough, not to mention if you have lots of metadata blocks to set. That will require you to do lots of testing to make sure you get them facing the right direction - they're a real pain to figure out as each block is different, but you know that. I can't count how many times I was sure I was setting the metadata to the correct facing only to find it opposite to my expectations >.< Very frustrating >.<
Good news is, once it's done, it will be a cinch to generate them facing whichever way you want, higher, lower, more to the right, more to the left and offset rotation, etc. and all the metadata will be set correctly for you Sure will make building a nice town easy!
Well, you have seen the code I have now, took me 5 days just to get every structure to be in front of the player no matter which way the player faced. Wasn't hard to do I had the code from another mod I made some time ago. The amount of structures is what made it so time consuming. I have 5 sets of structures now, 4 villages and one set of custom unique homes (gonna be the hardest to do, they are large). I also have 3 more sets planned, but after these are done, those should be cake. This will be a nice alternative to using schematics, as that is not exactly easy either, so many things can go wrong...bad schematic, bad blocks, custom blocks used in design, etc....
This forum should give pseudo awards like....
Modder of the month
Coder of the week
Builder of the week
It can handle tile entities because schematics are made from a world save file so have easy access to NBT data. If you can figure out a way to get me the NBT, I can just as easily incorporate that into my tool.
Btw, I realized just as I was going to bed that deleting structures is very simple - added it in!
It can handle tile entities because schematics are made from a world save file so have easy access to NBT data. If you can figure out a way to get me the NBT, I can just as easily incorporate that into my tool.
Btw, I realized just as I was going to bed that deleting structures is very simple - added it in!
I saw the post, very informative as always. I have tried using the tool that Mazetar pointed out, LibSchematic. I kept having issues finding and creating a schematic that would work. I think it may have something to do with me too, I could have just been getting it all wrong. I have always for myself found it easier to use worldgen files, lot easier for me to manipulate block wise and adding in some other nice things was easy. Though I am sure we all can agree, they both have positives and negatives to both which will lead us all to make a personal choice. For me, it was this...
And especially, thanks for the delete option as well, gonna be very nice. As for the NBT, I am not quite sure what you would need. I did work on the fossil and archaeology revival mod team at one point in the beginning, I have the files still for all the long and short tags that we used before I switched to this way of generating. There were lots of NBT stuff in those, however, they are from 1.3.2 though I may still have the 1.4.6 stuff too, should be basically the same.
Added some pics of structure removal to the other page. Since you're using a block to activate, it won't be a problem accidentally clicking the wrong block, but if you're using an Item version, it's best to aim precisely. However, even if you don't, since the structure is usually generated flat on the ground, you can click anywhere on the ground and it will just level it if it isn't already.
As for the NBT, I'm not sure how to explain it clearly. When playing Minecraft, most everything gets written to external NBT files to save data. However, if you're trying to generate a structure from scratch, you don't have the benefit of schematics that get to save all that data from within Minecraft (I think, anyway).
So how do you create those data files? And where are they located? If you can create a tile entity data file, then I could probably find a way to read it which is all I'd need to do to set it in the world within the structure generation.
As you can tell, I haven't done any save file editing, but if you or anyone has, I'm guessing that would be a way to do it. I wonder if there is already a tool / API that allows one to create / edit NBT files for various objects? That would save a lot of time trying to do it from scratch.
I am thinking there is a tool for that in the tool section. I will look after a bit and let you know what I find...just got up and need to mow the lawn....
Well, the solution was to not use NBT. I realized that since we are generating NEW structures, there wouldn't be any saved data anyways, so I added abstract methods for the user to define that allows for setting tile entity data and whatever else you can think to do.
The examples I provided in the mod code generate a chest with custom loot and a villager with a specified ID, but the options are basically limited only by your coding ability. Some of it, such as the villager ID, you can code right into the structure's blockArray by using the 'customData' index of the final array. Take a look at the StructureArrays.java file for a more in-depth explanation of how it all works.
Sometimes the villager will spawn in a wall. I'm not sure why, but I think it might have to do with the vanilla spawnEntityInWorld method, as the coordinates I give it are definitely NOT in the wall. Most times, the villager is fine. The hut is pretty small inside, only 2 blocks wide, so I'm sure if you just made sure to spawn them in a slightly larger open space, you wouldn't have this issue.
Also, I've found spawning villagers from their head level instead of foot level seems to work better.
Btw, I tested out using custom block ids and it worked fine for generating the block in the structure; however, there is currently no way to set rotation for custom blocks. I will be adding that next
Alright, custom block compatibility now implemented. Use the addCustomBlockRotation method to define your custom block's rotation type, such as WALL_MOUNTED or PISTON_CONTAINER. Check StructureArrays.java for full instructions. Enjoy!
Breaking the 5000 block barrier! Witness the 15-story tower of power, er, I mean, blacksmith tower. At 480 blocks apiece, this is a total of 7200 blocks. 2200 greater than static array initialization limits This was just a test, but you could probably build any size structure this way. Be warned, it gets laggy. This structure took about 4-5 seconds to show up.
First - A good place to start, as I have mentioned to many others, and also where I first learned how to do this, is by following wuppy21's guide for structure generation. His guide is for 1.3.2 but still works very well, with a few minor fixes here and there which I will explain later. You will also need a few tools, as mentioned in wuppy21's thread, or you can do this just by coding it out on paper and trying it out ( I dont recommend this for any beginner, much harder than doing it the easy way which may take longer depending on how big your structure is.
Second - You will need some tools, as mentioned in the tutorial by wuppy21. You will need a schematic to java converter and also MCEdit. Some of you may know also that it is possible to, with forge and also modloader, to import schematic files directly into the world. While this is possible, I personally do not like this way because of how some schematics may have errors, or are old and have some misplaced blocks that will produce strange errors, or have custom blocks left over from a mod that was used in creating the schematic, or any other number of issues that can arise.
Schematic converter #1 - Recommended Version as it supports Metadata
Schematic Converter #2 - Not recommended, not meta support as well as only provides block ID, not the block names.
Schematic Converter #3 - This is a new tool shown to me by Bendonnelly1. Not quite sure of how well this will work I have not tested it myself yet, but seems like it will be a much better tool for larger schematics.
MCEdit - we should have all heard of this tool by now
Information on using these tools will be posted later, for now you can view the pages for detailed information or watch the videos by wuppy21 using the link above.
Getting Started - The Basics
Once we have the tools above we must get some schematics, you may ask how do we do this. Well, first we could create a new world and build the structure we want, the way we want it, however because the convert tool is for 1.3.2, you should limit you block choices to blocks from that version and below. Dont worry we can change them later. Now that you have your structure built, load or run MCEdit and load your world you just created and locate your structure, select your structure and export as a schematic. Now we can use our converter to convert the schematic to a java file. Once we have done that we will have a file that looks like this....
/* *** MADE BY MITHION'S .SCHEMATIC TO JAVA CONVERTING TOOL v1.6 *** */ package net.minecraft.src; import java.util.Random; public class academy1 extends WorldGenerator { public academy1() { } public boolean generate(World world, Random rand, int i, int j, int k) { world.setBlock(i + 0, j + 0, k + 0, Block.dirt.blockID); world.setBlock(i + 0, j + 0, k + 1, Block.dirt.blockID); world.setBlock(i + 0, j + 0, k + 2, Block.dirt.blockID); world.setBlock(i + 0, j + 0, k + 3, Block.dirt.blockID); world.setBlock(i + 0, j + 0, k + 4, Block.dirt.blockID); return true; } }I am sure yours will have a lot more code in it, this is just an example. However you will need to make sure you scan your code because the new 1.5.x changed some things in the way ore, trees, plants, and structures are generated. The above will work just fine as the dirt block has no metadata or notifications to worry about. The following will not work with out having some changes made to the code....
The above should look like this....
This is the way I have it in my mod now and it works just fine, there may be another way to do this, but this is what works for me. Another thing to be on the watch for is errors in the conversion. One such error you will need to know to watch for as it will not always show the error is negative integers or block ID's. A negative value in the block ID will crash the game with a null exception error, and will point to your structure class. They may look like this....
Easiest way to fix these is to first comment them all out and get the structure generating first. Then you can go back and substitute them for the correct blocks if you know what they are, or just change them to a block type that is not in the structure, good ones to use that stand out are block diamond, block gold, haybale or anything else that stands out and is not already a part of the structure.
Now, you may be thinking, but wait, Microjunk, you havent told us how to generate the structure. Okay, there are several ways to do this as well. Structures can be generated using the same methods as Ore, Trees, Plants, or anything else that has to be generated in the world. They can also be generated using commands if you so choose to set them up that way or by block activation. For typical world gen like flowers and trees, you will need to add one line of code to your mod class and create one new class like this.
The above goes in your mod class, and the following is the new class
import net.minecraft.world.chunk.IChunkProvider; import cpw.mods.fml.common.IWorldGenerator; public class WorldGeneratorYourStructure implements IWorldGenerator { public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { case -1: generateNether(world, random, chunkX*16, chunkZ*16); case 0: generateSurface(world, random, chunkX*16, chunkZ*16); } } private void generateSurface(World world, Random rand, int chunkX, int chunkZ) { WorldGeneratorYourStructure tree = new WorldGeneratorYourStructure(); for(int x = 0;x<2;x++) { int i = chunkX + rand.nextInt(16); int k = chunkZ + rand.nextInt(16); int j = world.getHeightValue(i, k); tree.generate(world, rand, i, j, k); } } private void generateNether(World world, Random random, int blockX, int blockZ) { } }There are other ways to do this, but this is the most common way. If you want them to generate using commands, you will need a command tutorial for that, as I dont know. You can also do this with onBlockActivated in your block class like this....
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par2, float par3, float par4, float par5) { world.setBlock(i, j, k, 0); this.gen(world, rand, i, j, k); } return true; } public void gen(World world, Random rand, int i, int j, int k) { world.setBlock(i, j, k, 0); WorldGenYourStructure gen = new WorldGenYourStructure(); if (!gen.generate(world, rand, i, j, k)) { world.setBlock(i, j, k, this.blockID); } }The above will set your block to zero(remove the block) and generate your structure. Now, your structure may not generate in front of you, but there are ways of fixing this, and will be covered in another tutorial for advanced generation.
More will be added to this later as I find more to add, as I said this is for beginners and this is pretty basic stuff....Good Luck and have fun and happy generating....
For a much more advanced way of of generating your structures, adding in proper rotation, placement, and positioning, have a look at this post here by coolAlias. If this link does not work, it is post number 7 on this page.
Find out how I generate....coolAlias...world structure generation and rotation tool...
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumFind out how I generate....coolAlias...world structure generation and rotation tool...
Bookmarked for reference and I will also add it to the list of tools. After as many google searches I feel I got scroogled out of this one. I did not know about this at all. Now if we can just get one that turns them into component pieces for adding to villages on world generation.
Thanks for the tip, much appreciated.
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumAlright, the moment you've all been waiting for!!!! Okay, maybe just Micro's been waiting for it, but here it is
I've created a standalone tool that allows you to rotate, offset and change the default orientation of your custom structures when you generate them in the world, or even change it on the fly between adding structures with a block or item. The only caveat is your structure must be stored in an array format, specifically an int[][][][]
Don't worry, I've provided an example and a template, and there might be some handy tools around somewhere to convert from schematics / mcedit to code or array form. If not, it is a lot of work to set up, but no more than writing all those lines in the WorldGen file and it pays you back with a lot of flexibility.
There is only 1 necessary file to include in your mods if you want to use my tool, called WorldGenStructure, and another file called StructureArrays that will show you how to set up your structures for use with my tool, though it isn't necessary to include in your mod.
I've also included a standalone mini-mod that demonstrates the functionality of my tool without you having to set anything up. Read the readme file on github for more information about it.
Here are some screen shots from testing:
A row of houses generated without me taking a single step.
A structure correctly removed after generated - note that blocks that can drop as items often do:
An incorrectly removed structure - I spawned it on the block where the stairs go, so when I tried to remove it my 'y' position was one block higher due to the stairs:
A pic that doesn't do justice the massively sprawling hutropolis I spawned making this:
If you're needing help understanding how to set up your structure array, here's an explanation of how arrays work that may help:
You all know what an array is, but did you know that each value in an array can store another array?
Make a single array that stores ints, our y values:
int[] y = {5, 10, 2, 39};
It has 4 values stored at locations y[0],y[1], etc.
But we can make y[0] not store a value, but store an array of integers instead:
int[][] y = { { 5 }, {10}, {2}, {39} };
Note we have the same values, but now they are stored at:
y[0][0] = 5, y[1][0] = 10, y[2][0] = 2, etc.
Adding more values:
int[][] y = { { 5,10,2,39 }, {7,3,16 } };
Now we've made it so y[0] stores the array [0] = 5, [1] = 10, etc. and
y[1] stores the array [0] = 7, [1] = 3, etc.
Note that arrays defined this way (i.e. with { } ) are static and can store different numbers of variables in each array - they don't have to have the same length.
Thinking in terms of structures, then, we need an array to store all of our y values, and for each y value we must store an array of x values, and for each x value we must store an array of z values, giving us a 3D matrix:
int[][][] 3d = { {
{ 0,1,2 }, { 0,1,2 },{ 0,1,2 } }, // y = 0, 3 x values that each store z = 0, 1, 2
{ 0,1,2 }, { 0,1,2 },{ 0,1,2 } }, // y = 1, 3 x values that each store z = 0, 1, 2
{ 0,1,2 }, { 0,1,2 },{ 0,1,2 } } }; // y = 2, 3 x values that each store z = 0, 1, 2
However, we need to store more than a single int at our location x,y,z, because we need block ID, metadata and possibly a flag, so each of our z values must also store an array.
Thus the 4 dimensional array used for storing structures.
Thank you ever so much for this, your time and effort is absolutely worth every bit of what this will do....
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumGood news is, once it's done, it will be a cinch to generate them facing whichever way you want, higher, lower, more to the right, more to the left and offset rotation, etc. and all the metadata will be set correctly for you
This forum should give pseudo awards like....
Modder of the month
Coder of the week
Builder of the week
Things like that...you'd get my vote
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumMazetar, however, pointed out another really great tool that does all this and more for schematics: https://github.com/t...rd/LibSchematic.
It can handle tile entities because schematics are made from a world save file so have easy access to NBT data. If you can figure out a way to get me the NBT, I can just as easily incorporate that into my tool.
Btw, I realized just as I was going to bed that deleting structures is very simple - added it in!
I saw the post, very informative as always. I have tried using the tool that Mazetar pointed out, LibSchematic. I kept having issues finding and creating a schematic that would work. I think it may have something to do with me too, I could have just been getting it all wrong. I have always for myself found it easier to use worldgen files, lot easier for me to manipulate block wise and adding in some other nice things was easy. Though I am sure we all can agree, they both have positives and negatives to both which will lead us all to make a personal choice. For me, it was this...
And especially, thanks for the delete option as well, gonna be very nice. As for the NBT, I am not quite sure what you would need. I did work on the fossil and archaeology revival mod team at one point in the beginning, I have the files still for all the long and short tags that we used before I switched to this way of generating. There were lots of NBT stuff in those, however, they are from 1.3.2 though I may still have the 1.4.6 stuff too, should be basically the same.
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumAs for the NBT, I'm not sure how to explain it clearly. When playing Minecraft, most everything gets written to external NBT files to save data. However, if you're trying to generate a structure from scratch, you don't have the benefit of schematics that get to save all that data from within Minecraft (I think, anyway).
So how do you create those data files? And where are they located? If you can create a tile entity data file, then I could probably find a way to read it which is all I'd need to do to set it in the world within the structure generation.
As you can tell, I haven't done any save file editing, but if you or anyone has, I'm guessing that would be a way to do it. I wonder if there is already a tool / API that allows one to create / edit NBT files for various objects? That would save a lot of time trying to do it from scratch.
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThe examples I provided in the mod code generate a chest with custom loot and a villager with a specified ID, but the options are basically limited only by your coding ability. Some of it, such as the villager ID, you can code right into the structure's blockArray by using the 'customData' index of the final array. Take a look at the StructureArrays.java file for a more in-depth explanation of how it all works.
Sometimes the villager will spawn in a wall. I'm not sure why, but I think it might have to do with the vanilla spawnEntityInWorld method, as the coordinates I give it are definitely NOT in the wall. Most times, the villager is fine. The hut is pretty small inside, only 2 blocks wide, so I'm sure if you just made sure to spawn them in a slightly larger open space, you wouldn't have this issue.
Also, I've found spawning villagers from their head level instead of foot level seems to work better.
Btw, I tested out using custom block ids and it worked fine for generating the block in the structure; however, there is currently no way to set rotation for custom blocks. I will be adding that next
Find out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumFind out how I generate....coolAlias...world structure generation and rotation tool...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumBreaking the 5000 block barrier! Witness the 15-story tower of power, er, I mean, blacksmith tower. At 480 blocks apiece, this is a total of 7200 blocks. 2200 greater than static array initialization limits
Code will be up once I double-check some things
Find out how I generate....coolAlias...world structure generation and rotation tool...
Thank you very Much for the tutorial