I know, this is a little bit of an old thread,but I have a similar Problem and tried to solve it with the code provided by diesieben07:
For a mod I am writing at the Moment (PoorOres) I need to disable worldgen for the ores I add myself. to do that I used the following code:
public void onEvent(PopulateChunkEvent.Pre event)
{
// replace all oreblocks of a type with stone
// diesieben07 came up with this method (http://www.minecraftforge.net/forum/index.php/topic,21625.0.html)
Chunk chunk = event.world.getChunkFromChunkCoords(event.chunkX, event.chunkZ);
for (ExtendedBlockStorage storage : chunk.getBlockStorageArray())
{
if (storage != null)
{
for (int x = 0; x < 16; ++x)
{
for (int y = 0; y < 16; ++y)
{
for (int z = 0; z < 16; ++z)
{
Block curBlock = storage.getBlockByExtId(x, y, z);
for (PoorOre poorOre : Reference.WORLDGEN) {
if (curBlock == poorOre.getBaseBlock()) {
// LogHelper.info("Replace " + poorOre.getBaseBlock().getLocalizedName() + " at " + x + ", " + y + ", " + z + " with " + poorOre.getUnderlyingBlock().getLocalizedName());
storage.func_150818_a(x, y, z, poorOre.getUnderlyingBlock());
}
}
}
}
}
}
}
chunk.isModified = true; // this is important as it marks it to be saved
}
Any idea, what I am doing wrong? It works fine, when I try to replace stone or grass.
Edit: found out, what I was doing wrong. I simply used the OreGenEvent.GenerateMinable event instead and now it works like a charm.