import * as mc from "@minecraft/server";
/**
 * @remarks Creates an explosion from a command.
 * @example
 * sample.mcfunction
 * ```mcfunction
 * scriptevent ldz:explosion {"radius": 1}
 * ```
 */
export function initializeExplosionHandler() {
    mc.system.afterEvents.scriptEventReceive.subscribe(event => {
        if (event.id === 'ldz:explosion' && event.sourceEntity) {
            let explosionData = { radius: 1 };
            if (event.message) {
                explosionData = Object.assign(Object.assign({}, explosionData), JSON.parse(event.message));
            }
            event.sourceEntity.dimension.createExplosion(event.sourceEntity.location, explosionData.radius, explosionData);
        }
    });
}
