I am adding a new feature to the Builder mod in which when you generate the village structures a villager also spawns with it. However the code I am using....
EntityVillager vill = new EntityVillager(world);
vill.setPosition(i + 2, j + 1, k + 4);
world.spawnEntityInWorld(vill);
Only spawns a basic villager. Is there a way to utilize metadata in this to spawn say, a black smith in the blacksmith shop? or the priest in the church?
/**
* Returns the villager type to spawn in this component, based on the number of villagers already spawned.
*/
protected int getVillagerType(int par1)
{
return 2;
}
}
I spawned a custom villager for my Village Taverns mod. You can check out the source code on the github
I will take a look through your code this night at work and see what I can find, but if its like the above solution it may not help as I am generating structures instantly and this all has to be done in the worldgenerator class, so there is not much I can do with out rewriting the code from scratch for this....
I spawned a custom villager for my Village Taverns mod. You can check out the source code on the github
Thanks for the look into your code, however, as I said above I am using world gen for my structures not a component setup the way MC does it. Basically this is because this is essentially an instant structure type mod. Though the basic intentions for the mod was for map makers and those who just wish to spawn and create villages the way they want to and in some pattern they want to. And for each of the different types of villages I have, I wanted to spawn a villager for the structure type they fit to best. I have villagers spawning, just not the villager I want. So I guess what I am after is how to set this up to spawn the exact villager I want without having to code in the structures in the way MC does it as this confuses me.
Take a look at the setProfession function in villager. You're getting a basic villager because a profession isn't set in the constructor for villagers. You have to make a call to the function after the villagers created.
Edit: Well, I just looked at the code for spawning villagers in the village code, in there when it created a new villager it supposively ownly spawns default villagers
/**
* Spawns a number of villagers in this component. Parameters: world, component bounding box, x offset, y offset, z
* offset, number of villagers
*/
protected void spawnVillagers(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6)
{
if (this.villagersSpawned < par6)
{
for (int var7 = this.villagersSpawned; var7 < par6; ++var7)
{
int var8 = this.getXWithOffset(par3 + var7, par5);
int var9 = this.getYWithOffset(par4);
int var10 = this.getZWithOffset(par3 + var7, par5);
if (!par2StructureBoundingBox.isVecInside(var8, var9, var10))
{
break;
}
++this.villagersSpawned;
EntityVillager var11 = new EntityVillager(par1World, this.getVillagerType(var7));
var11.setLocationAndAngles((double)var8 + 0.5D, (double)var9, (double)var10 + 0.5D, 0.0F, 0.0F);
par1World.spawnEntityInWorld(var11);
}
}
}
/**
* Returns the villager type to spawn in this component, based on the number of villagers already spawned.
*/
protected int getVillagerType(int par1)
{
return 0;
}
I figured getVillagerType would have been some sort of function determining which type of mob to spawn but apperantly they just return it to default. Thats probably why you get bad villager trades when you first find them.
Need a good universal mob farm? Check out the Double Shift Towers. Designed for 1.9 and gets 22,000 Items / Hour with a very simple redstone set up - https://www.youtube.com/watch?v=jL8aoJpjjgU
im not quite sure how that will help. The get and set profession is set by datawatcher so I really dont think that will help at all. As I said this is all being done upon generation of the structure. I am also extending WorldGenerator, not making a component so, do you have an example on how to use the code you referenced, that may help.
There was some interesting work done by Lunatrius on a project called Schematica (github) where he was generating a sort of overlay world within the world. Might be of some use to you, as it uses a file format that some other tools also use.
I have villagers spawning, just not the villager I want. ...And for each of the different types of villages I have, I wanted to spawn a villager for the structure type they fit to best.
I haven't worked with worldgen extensions, so I'm not sure what all goes into that. But lots of mods add buildings, and those buildings have a public function ComponentVillageWhatever.getVillagerType(int) which returns an int specifying the type of villager. I haven't gone looking for a list of vanilla villager types, but mods that add villager types are gonna have custom VillageHandlerMyNewVillager classes for their new villager types.
Right, I got that much, but I am trying to spawn vanilla villagers, not custom. I actually looked into the VillageHandler and it wasnt of any real usefulness for me as most of the code there is for custom stuff. I will look into the other method though when I get home as I havent seen that one yet so it may help some. I hope I can get this because I am no good at recreating the components, I have tried and failed many times which is why I went this route where I just generate the structure from a block click or activation. If I can figure out which method works for me, I can always just modify the code I have now to suit. I would hate to have to abandon the idea all together. The link for schematica will help me some as well I hope as I am trying to find some way to generate the structures and also give the ability to rotate them to be placed they way the player wants. My aim is to make an instant structure mod unlike any other....
Only spawns a basic villager. Is there a way to utilize metadata in this to spawn say, a black smith in the blacksmith shop? or the priest in the church?
Find out how I generate....coolAlias...world structure generation and rotation tool...
hint : net.minecraft.world.gen.structure;
In addcomponentparts ():
this.spawnVillagers(par1World, par3StructureBoundingBox, 2, 1, 2, 1);
/**
* Returns the villager type to spawn in this component, based on the number of villagers already spawned.
*/
protected int getVillagerType(int par1)
{
return 2;
}
}
Find out how I generate....coolAlias...world structure generation and rotation tool...
My five-point rating system: Yay, kay, meh, erm, gleh
This is just not working at all...or I just dont understand enough about the village structure component gen classes to get it....
I will take a look through your code this night at work and see what I can find, but if its like the above solution it may not help as I am generating structures instantly and this all has to be done in the worldgenerator class, so there is not much I can do with out rewriting the code from scratch for this....
Find out how I generate....coolAlias...world structure generation and rotation tool...
Thanks for the look into your code, however, as I said above I am using world gen for my structures not a component setup the way MC does it. Basically this is because this is essentially an instant structure type mod. Though the basic intentions for the mod was for map makers and those who just wish to spawn and create villages the way they want to and in some pattern they want to. And for each of the different types of villages I have, I wanted to spawn a villager for the structure type they fit to best. I have villagers spawning, just not the villager I want. So I guess what I am after is how to set this up to spawn the exact villager I want without having to code in the structures in the way MC does it as this confuses me.
Find out how I generate....coolAlias...world structure generation and rotation tool...
Edit: Well, I just looked at the code for spawning villagers in the village code, in there when it created a new villager it supposively ownly spawns default villagers
I figured getVillagerType would have been some sort of function determining which type of mob to spawn but apperantly they just return it to default. Thats probably why you get bad villager trades when you first find them.
Bored enough to watch some vanilla lets plays? http://www.youtube.com/user/Crump3txxix
Need a good universal mob farm? Check out the Double Shift Towers. Designed for 1.9 and gets 22,000 Items / Hour with a very simple redstone set up - https://www.youtube.com/watch?v=jL8aoJpjjgU
Find out how I generate....coolAlias...world structure generation and rotation tool...
I haven't worked with worldgen extensions, so I'm not sure what all goes into that. But lots of mods add buildings, and those buildings have a public function ComponentVillageWhatever.getVillagerType(int) which returns an int specifying the type of villager. I haven't gone looking for a list of vanilla villager types, but mods that add villager types are gonna have custom VillageHandlerMyNewVillager classes for their new villager types.
My five-point rating system: Yay, kay, meh, erm, gleh
Find out how I generate....coolAlias...world structure generation and rotation tool...
The getVillagerType returns an integer, so modify it like this:
to spawn a Blacksmith
Ahhh, yes. Thanks that was exactly what I needed.....
Find out how I generate....coolAlias...world structure generation and rotation tool...