#My script to remove ores doesn't work(

10 messages · Page 1 of 1 (latest)

devout laurel
#

script:

    const world = event.server.world

    world.events.chunkLoad(event => {
        const chunk = event.chunk

        const markerPos = { x: 8, y: chunk.getMaxBuildHeight() - 1, z: 8 }
        const markerBlock = chunk.getBlockState(markerPos.x, markerPos.y, markerPos.z)

        if (markerBlock.getBlock() !== 'minecraft:barrier') {

            for (let x = 0; x < 16; x++) {
                for (let y = 0; y < chunk.getMaxBuildHeight(); y++) {
                    for (let z = 0; z < 16; z++) {
                        let blockState = chunk.getBlockState(x, y, z)
                        
                        let oresToRemove = [
                            'minecraft:coal_ore',
                            'minecraft:iron_ore',
                            'minecraft:copper_ore',
                            'minecraft:gold_ore',
                            'minecraft:diamond_ore',
                            'minecraft:emerald_ore',
                            'minecraft:redstone_ore',
                            'minecraft:lapis_ore'
                            
                        ]

                        if (oresToRemove.includes(blockState.getBlock().getRegistryName())) {
                            chunk.setBlockState(x, y, z, 'minecraft:stone')
                        }
                    }
                }
            }
           
            chunk.setBlockState(markerPos.x, markerPos.y, markerPos.z, 'minecraft:barrier')
        }
    })
})
iron muskBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

remote kiln
#

is this ai?

nova bridgeBOT
#

NEVER use any AI to generate KubeJS code. They currently know very little about it, and what they do know is often outdated or false. You can instead look at the KubeJS wiki or ask for help in #1047320998199955458.

#

Choose a topic below!

remote kiln
#

this is the example of the wiki:

WorldgenEvents.remove(event => {
  // print all features for a given biome filter
  event.printFeatures('', 'minecraft:plains')

  event.removeOres(props => {
    // much like ADDING ores, this supports filtering by worldgen layer...
    props.worldgenLayer = 'underground_ores'
    // ...and by biome
    props.biomes = [
      { category: 'icy' },
      { category: 'savanna' },
      { category: 'mesa' }
    ]

    // BlockStatePredicate to remove iron and copper ores from the given biomes
    // Note tags may NOT be used here, unfortunately...
    props.blocks = ['minecraft:iron_ore', 'minecraft:copper_ore']
  })

  // remove features by their id (first argument is a generation step)
  event.removeFeatureById('underground_ores', ['minecraft:ore_coal_upper', 'minecraft:ore_coal_lower'])
})
remote kiln
#

almost at the bottom