pocketmine\event\entity\EntityEatEvent::__construct PHP Method

__construct() public method

public __construct ( Entity $entity, pocketmine\item\FoodSource $foodSource )
$entity pocketmine\entity\Entity
$foodSource pocketmine\item\FoodSource
    public function __construct(Entity $entity, FoodSource $foodSource)
    {
        $this->entity = $entity;
        $this->foodSource = $foodSource;
        $this->foodRestore = $foodSource->getFoodRestore();
        $this->saturationRestore = $foodSource->getSaturationRestore();
        $this->residue = $foodSource->getResidue();
        $this->additionalEffects = $foodSource->getAdditionalEffects();
    }

Usage Example

 public function __construct(Entity $entity, FoodSource $foodSource)
 {
     if (!$foodSource instanceof Block) {
         throw new \InvalidArgumentException("Food source must be a block");
     }
     parent::__construct($entity, $foodSource);
 }
All Usage Examples Of pocketmine\event\entity\EntityEatEvent::__construct