#Getting a mob's drops on right click

4 messages · Page 1 of 1 (latest)

tawdry ferry
#

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
      );
    }
  }
});
tranquil heronBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

sharp bay
#
ItemEvents.rightClicked(e => {
    e.server.tell(Utils.rollChestLoot('minecraft:entities/cow'))
})
tawdry ferry
#

Thank you, exactly what I'm lookin for