const CREATE_SAIL_COLORS = [
    'white',
    'orange',
    'magenta',
    'light_blue',
    'yellow',
    'lime',
    'pink',
    'gray',
    'light_gray',
    'cyan',
    'purple',
    'blue',
    'brown',
    'green',
    'red',
    'black'
]

const BURNING_CREATE_GENERATOR_BLOCKS = [
    'create:windmill_bearing',
    'create:sail_frame',
    'create:water_wheel',
    'create:large_water_wheel'
]



CREATE_SAIL_COLORS.forEach(color => {
    BURNING_CREATE_GENERATOR_BLOCKS.push(`create:${color}_sail`)
})



BlockEvents.placed(event => {
    const level = event.level
    const block = event.block

    if (level.dimension !== 'minecraft:the_nether') return
    if (!BURNING_CREATE_GENERATOR_BLOCKS.includes(block.id)) return

    const x = block.x
    const y = block.y
    const z = block.z

    block.set('minecraft:fire')
    level.runCommandSilent(`particle minecraft:flame ${x + 0.5} ${y + 0.5} ${z + 0.5} 0.35 0.35 0.35 0.03 18`)
    level.runCommandSilent(`particle minecraft:smoke ${x + 0.5} ${y + 0.5} ${z + 0.5} 0.35 0.35 0.35 0.02 10`)
    level.runCommandSilent(`playsound minecraft:item.firecharge.use block @a[distance=..16] ${x + 0.5} ${y + 0.5} ${z + 0.5} 0.8 1.0`)

    if (event.player) {
        event.player.tell('Primitive kinetic generators burn up when placed in Nether.')
    }
})
