World generator without ores

Discussion in 'Plugin Development' started by filoghost, Aug 30, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    filoghost

    Hello, I'm trying to create a simple world generator, with the normal world, but without ores. What is the most efficient way to achieve this, check all the blocks when a new chunk is generated, or create a custom world generator? And how?
     
  2. filoghost
    I'd just loop through the blocks in ChunkLoadEvent, check if the the block name contains "ORE", if so, set the block type to stone (or air, which one you prefer).
    Code:java
    1. @EventHandler
    2. public void onChunkLoad(ChunkLoadEvent event) {
    3. if (event.isNewChunk()) {
    4. Chunk c = event.getChunk();
    5. for (int x = c.getX(); x <= c.getX() + 16; x++) {
    6. for (int y = 256; y >= 0; y--) {
    7. for (int z = c.getZ(); z <= c.getZ() + 16; z++) {
    8. Block b = c.getBlock(x, y, z);
    9. if (b.getType().toString().contains("ORE")) {
    10. b.setType(Material.STONE);
    11. }
    12. }
    13. }
    14. }
    15. }
    16. }
     
  3. Offline

    filoghost

    This would check the entire chunk, is there a way to do it when the world generates?
     
  4. filoghost
    Well you'd have to make a custom world generator then, since you can't modify the terrain if the chunk is not loaded (and since the world is just loading, it's not).
     
  5. Offline

    filoghost

    That's what I'm trying to do. I found the ChunkPopulateEvent, but I would like to remove caves and lava also.
     
Thread Status:
Not open for further replies.

Share This Page