Hello. I working on a Gravestone mod, one ability of which is generation of cemeteries in villages. But i have some problems with it. It require to modify StructureVillagePieces class. Is some one know how i can add new building without changing this class, like in a "forestry mod"?
After some time of searching i found solution of my problem, and i think it may be helpful for someone.
you must create additional class
public class VillageHandlerYourBuilding implements VillagerRegistry.IVillageCreationHandler {
public StructureVillagePieceWeight getVillagePieceWeight(Random random, int size) {
return new StructureVillagePieceWeight(ComponentVillageYourBuilding.class, 4, MathHelper.getRandomIntegerInRange(random, 0, 1));
}
public Class getComponentClass() {
return ComponentVillageYourBuilding.class;
}
public Object buildComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) {
return ComponentVillageYourBuilding.buildComponent(startPiece, pieces, random, p1, p2, p3, p4, p5);
}
}
and forge's registerVillageCreationHandler method of VillagerRegistry class
VillageHandlerYourBuilding villageHandler = new VillageHandlerYourBuilding();
VillagerRegistry.instance().registerVillageCreationHandler(villageHandler);
Have you created a ComponentVillageYourBuilding class? What does it look like? I'de love to mess around with adding new buildings to the testificate villages.
Rollback Post to RevisionRollBack
My five-point rating system: Yay, kay, meh, erm, gleh
Have you created a ComponentVillageYourBuilding class? What does it look like?
Yes
public class ComponentVillageYourBuilding extends ComponentVillage {
private int averageGroundLevel = -1;
private static final int HEIGHT = 2;
public ComponentVillageYourBuilding(ComponentVillageStartPiece par1ComponentVillageStartPiece, int componentType, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) {
super(par1ComponentVillageStartPiece, componentType);
this.coordBaseMode = par5;
this.boundingBox = par4StructureBoundingBox;
}
public static ComponentVillageYourBuilding buildComponent(ComponentVillageStartPiece startPiece, List par1List, Random random, int par3, int par4, int par5, int par6, int par7) {
StructureBoundingBox var8 = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 12, HEIGHT, 10, par6);
return canVillageGoDeeper(var8) && StructureComponent.findIntersecting(par1List, var8) == null ? new ComponentVillageYourBuilding(startPiece, par7, random, var8, par6) : null;
}
// this method create house
public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) {
if (this.averageGroundLevel < 0) {
this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox);
if (this.averageGroundLevel < 0) {
return true;
}
this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + HEIGHT - 1, 0);
}
// place generation house code here
this.spawnVillagers(par1World, par3StructureBoundingBox, X, Y, Z, COUNT);
return true;
}
// add this method if villagers will be spawn in your building
protected int getVillagerType(int par1) {
return VILLAGER_TYPE;
}
}
it is almost like another village's buildings classes in net.minecraft.world.gen.structure package
Could you post this please?
It would be useful to my mod.
Here you can find it. But it is too old, and there are a lot of changes in my code since i wrote it.
So check my sources too, they are available on my github.
you must create additional class
and forge's registerVillageCreationHandler method of VillagerRegistry class
Have you created a ComponentVillageYourBuilding class? What does it look like? I'de love to mess around with adding new buildings to the testificate villages.
My five-point rating system: Yay, kay, meh, erm, gleh
Yes
it is almost like another village's buildings classes in net.minecraft.world.gen.structure package
Now I'm working on a own catacombs generation, and, if you need it, i'll post here my results...
Could you post this please?
It would be useful to my mod.
Legend of Zelda Mod (Minecraft 1.10.2!)[Updated September 10th 2016 to 4.0-pre2]
Extra Achievements (Minecraft 1.9.4!)[Updated July 8th 2016 to 2.3.3]
Here you can find it. But it is too old, and there are a lot of changes in my code since i wrote it.
So check my sources too, they are available on my github.