I'm trying to make the entities when killed drop into the player's inventory that executed that entity I'm On Pocketmine Version 3.28.0 - PM3 PHP: <?phpnamespace MasterFeio\entity\mob;use pocketmine\entity\Animal;use pocketmine\item\Item;use pocketmine\Player;use pocketmine\item\enchantment\Enchantment;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDeathEvent;class IronGolem extends Animal{ public const NETWORK_ID = self::IRON_GOLEM; public $width = 1.4; public $height = 2.7; public function getName(): string { return "Iron Golem"; } public function initEntity(): void{ $this->setMaxHealth(100); parent::initEntity(); } public function getDrops(): array { $lootingL = 1; $cause = $this->lastDamageCause; if($cause instanceof EntityDamageByEntityEvent){ $dmg = $cause->getDamager(); if($dmg instanceof Player){ $looting = $dmg->getInventory()->getItemInHand()->getEnchantment(Enchantment::LOOTING); if($looting !== null){ $lootingL = $looting->getLevel(); }else{ $lootingL = 1; } } } $iron = Item::get(Item::IRON_INGOT, 0, mt_rand(1, 2 * $lootingL)); $rose = Item::get(Item::RED_FLOWER, 0, 1 * $lootingL); if(mt_rand(0, 5) === 0) { return [$iron, $rose]; } return [$iron]; }}//I'm using this code in my entities.
By the way, what well I went to test the code, I just didn't understand where to put the entity's item inside the "return [];" Get more drops on the floor