// priority: 8
// 生物死亡事件
NativeEvents.onEvent($LivingDeathEvent, event => {
    let player = event.source?.player;
    if (!player) return;

    let effects = get_all_effect(player);

    effects.forEach(effect => {
        let strategy = all_effect_death_strategies[effect.name] || all_effect_death_strategies.default;
        strategy(event, player, effect.level, effect.name, effect.efficiency);
    });
});
const all_effect_death_strategies = {
    //炼金
    'alchemy': function (event, player, effectLevel, effectname, efficiency) {
        let random = Math.random();
        if (random < effectLevel / 100) {
            player.give(Item.of('minecraft:gold_block').withCount(1));
        }
    },
    'default': function (event, player, effectLevel, effectname, efficiency) {
        return;
    }
};