Skip to main content

WorldgenAddEventJS

This event isn't complete yet and can only do basic things. Feature removal event hasn't been added yet but will be in future

Example script: (kubejs/startup_scripts/worldgen.js)

onEvent('worldgen.add', event => {
  event.addLake(lake => {
    lake.block = 'minecraft:diamond_block'
    lake.chance = 3
  })

  event.addOre(ore => {
    ore.block = 'minecraft:glowstone'
    ore.spawnsIn.blacklist = false
    ore.spawnsIn.values = [
      '#minecraft:base_stone_overworld'
    ]
    
    ore.biomes.blacklist = true
    ore.biomes.values = [
      'minecraft:plains',
      '#nether'
    ]
    
    ore.clusterMinSize = 5
    ore.clusterMaxSize = 9
    ore.clusterCount = 30
    ore.minHeight = 0
    ore.maxHeight = 64
  })
  
  event.addSpawn(spawn => {
    spawn.category = 'creature'
    spawn.entity = 'minecraft:pig'
    spawn.weight = 10
    spawn.minCount = 4
    spawn.maxCount = 4
  })
})

All values are optional. All feature types have biomes field like addOre example

Valid biome categories (#category):

  • taiga
  • extreme_hills
  • jungle
  • mesa
  • plains
  • savanna
  • icy
  • the_end
  • beach
  • forest
  • ocean
  • desert
  • river
  • swamp
  • mushroom
  • nether

This is the order vanilla worldgen happens:

  1. raw_generation
  2. lakes
  3. local_modifications
  4. underground_structures
  5. surface_structures
  6. strongholds
  7. underground_ores
  8. underground_decoration
  9. vegetal_decoration
  10. top_layer_modification

It's possible you may not be able to generate some things in their layer, like ores in dirt, because dirt hasn't spawned yet. So you may have to change the layer by calling ore.worldgenLayer = 'top_layer_modification'