public function getDrops()
{
$lootingL = 0;
$cause = $this->lastDamageCause;
$drops = [];
if ($cause instanceof EntityDamageByEntityEvent and $cause->getDamager() instanceof Player) {
$lootingL = $cause->getDamager()->getItemInHand()->getEnchantmentLevel(Enchantment::TYPE_WEAPON_LOOTING);
if (mt_rand(0, 199) < 5 + 2 * $lootingL) {
switch (mt_rand(0, 3)) {
case 0:
$drops[] = ItemItem::get(ItemItem::IRON_INGOT, 0, 1);
break;
case 1:
$drops[] = ItemItem::get(ItemItem::CARROT, 0, 1);
break;
case 2:
$drops[] = ItemItem::get(ItemItem::POTATO, 0, 1);
break;
}
}
$count = mt_rand(0, 2 + $lootingL);
if ($count > 0) {
$drops[] = ItemItem::get(ItemItem::ROTTEN_FLESH, 0, $count);
}
}
return $drops;
}