import { ItemStack } from "@minecraft/server";
import { defaultDrop, wildMaterialDropMapping } from "../DATA/Config";
import { itemLoreConfig } from "../DATA/LoreConfig";
function spawnItemAt(dimensionData, location, itemId, quantity, loreLines) {
    const item = new ItemStack(itemId, quantity);
    if (loreLines?.length) {
        item.setLore(loreLines);
    }
    dimensionData.spawnItem(item, location);
}
function getRandomInteger(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
export function spawnItemForDeath(entityId, entityDimension, entityLocation, isWild, log) {
    if (isWild) {
        defaultDrop.forEach(({ itemId, quantity, loreLines, dropChance }) => {
            if (Math.random() <= (dropChance ?? 100) / 100) {
                spawnItemAt(entityDimension, entityLocation, itemId, getRandomInteger(...quantity), loreLines);
            }
        });
        const materialDrop = wildMaterialDropMapping[entityId];
        if (materialDrop) {
            for (let i = 0; i < 5; i++) {
                entityDimension.spawnEntity("minecraft:xp_orb", entityLocation);
            }
            if (Math.random() <= (materialDrop.chance ?? 100) / 100) {
                spawnItemAt(entityDimension, entityLocation, materialDrop.id, getRandomInteger(materialDrop.min, materialDrop.max), itemLoreConfig[materialDrop.id]);
            }
        }
    }
}

//# sourceMappingURL=../../../../../_KiCuMountsBPDebug/kicu/mmad/C/SpawnItem.js.map
