My aim is to make a custom item for getting a mob's drops without killing it. Is there a way to simulate the loot a mob would have dropped? Here's the code I'm trying to slot this into
ItemEvents.entityInteracted((e) => {
const { hand, player, item, target, level, server } = e;
if (hand == "OFF_HAND") return;
if (hand == "MAIN_HAND") {
player.swing();
if (item === "society:magic_shears") {
player.damageHeldItem("main_hand", 1)
// Get mob drops here. For example, a cow would drop leather and raw beef
server.runCommandSilent(
`playsound minecraft:entity.sheep.shear block @a ${player.x} ${player.y} ${player.z}`
);
level.spawnParticles(
"minecraft:angry_villager",
true,
target.x,
target.y + 1.5,
target.z,
0.2 * rnd(1, 4),
0.2 * rnd(1, 4),
0.2 * rnd(1, 4),
5,
0.01
);
}
}
});