BlockEvents.placed(event => {
    if (event.level.clientSide) return;

    let player = event.player;
    if (!player) return;

    let blockId = String(event.block.id);

    // Target common lighting blocks
    if (blockId.includes('torch') || blockId.includes('lantern')) {
        
        // 0.2% Chance (1 out of 500 placements)
        if (Math.random() < 0.002) {
            let username = player.username ? String(player.username) : String(player.getName().getString());
            
            // Snuff out the light block immediately back to air
            event.block.set('minecraft:air');

            // Play the deep, corrupted mechanical demonic scream (Pitch 0.4)
            event.server.runCommandSilent(`playsound minecraft:entity.enderman.scream ambient ${username} ~ ~ ~ 2.0 0.4`);
            event.server.runCommandSilent(`effect give ${username} minecraft:blindness 3 0 true`);
            
            player.setStatusMessage(Text.darkGray("Something blew out the flame before it could catch..."));
        }
    }
});