1.15.2 How can I slightly modify chunk generation?

Discussion in 'Spigot Plugin Development' started by HoiTemmieColeg, Mar 27, 2020.

  1. I want to modify the chunk generation so that a certain block spawns in veins like ores. I discovered this article which seems pretty useful, but this article is for making completely new generation. I only want to slightly modify the default underground generation. Does anyone have any ideas or tips on how to do this?
  2. I think I should elaborate. I want to give a Mob Spawner special data (when used with a resource pack it looks like a cool ore) and have it appear underground like ores do.

    I already know how to place the spawner with the special data, I just don't know how to make it appear naturally as the world generates.
  3. Use ChunkPopulateEvent

    Example: This will replace the diamond_ore with quartz_ore during world generation

    Code (Text):
        public void onChunkPopulate(ChunkPopulateEvent e)
            for (int x = 0; x < 16; x++)
                for (int y = 0; y <= 131; y++)
                    for (int z = 0; z < 16; z++)
                        Block block = e.getChunk().getBlock(x, y, z);
                        Material material = block.getType();
                        if (material.equals(Material.DIAMOND_ORE))
    • Agree Agree x 1
  4. Use block.setType(Material.NETHER_QUARTZ_ORE, false); to avoid crashes