//entity.js
import * as mc from "@minecraft/server";
export const Entity = {
    summonWhenBreakBlock: function (data, chance, blockType, entityType) {
        const id = data.block.typeId;
        if (id === blockType) {
            let randomChance = Math.floor(Math.random() * chance) + 1; //around 1 in chance
            
            if (randomChance === 1) {
                mc.system.run(() => {
                    const blockX = data.block.location.x;
                    const blockZ = data.block.location.z;
                    const centerX = blockX + 0.5;
                    const centerZ = blockZ + 0.5;
                    data.dimension.spawnEntity(entityType, {
                        x: centerX,
                        y: data.block.location.y,
                        z: centerZ
                    });
                });
            }
        }
    }
};
