Hello all,
Today I started to dive into modding Minecraft (with Forge 4).
I'm thinking of generating some pretty big structures, so I started messing around with a custom world generator. But one of my tests (simply adding some sort of brick stone roof with glass windows over the complete world) is generating really slow.
My IWorldGenerator implementation:
public class QWorldGenerator implements IWorldGenerator
{
protected WorldGenRoof roofGenerator = new WorldGenRoof();
// left out some inherited methods
private void generateSurface(World world, Random random, int x, int z)
{
roofGenerator.generate(world, random, x, 0, z);
}
}
The actual WorldGenerator:
public class WorldGenRoof extends WorldGenerator
{
public boolean generate(World world, Random random, int chunkX, int chunkY, int chunkZ)
{
int blockId = 0;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
blockId = Block.stoneBrick.blockID;
if (x > 6 && x < 13 && z > 6 && z < 13) {
blockId = Block.glass.blockID;
}
world.setBlock(chunkX + x, 100, chunkZ + z, blockId);
}
}
return true;
}
}
The code works fine, but as I said, really slow. It takes like five minutes instead of the normal couple of seconds to generate a new world.
When I remove the world.setBlock(...) there is no real drop in performance.
So is there some kind of other process I should use when doing things like this? Or maybe some mode to set while setting blocks in a loop? (I tried world.editingBlocks, but that didn't really help )
Any ideas welcome!