*/ class EntityExplodeEvent extends EntityEvent implements Cancellable{ use CancellableTrait; /** * @param Block[] $blocks * @param float $yield 0-100 */ public function __construct( Entity $entity, protected Position $position, protected array $blocks, protected float $yield ){ $this->entity = $entity; if($yield < 0.0 || $yield > 100.0){ throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0"); } } public function getPosition() : Position{ return $this->position; } /** * Returns a list of blocks destroyed by the explosion. * * @return Block[] */ public function getBlockList() : array{ return $this->blocks; } /** * Sets the blocks destroyed by the explosion. * * @param Block[] $blocks */ public function setBlockList(array $blocks) : void{ Utils::validateArrayValueType($blocks, function(Block $_) : void{}); $this->blocks = $blocks; } /** * Returns the percentage chance of drops from each block destroyed by the explosion. * @return float 0-100 */ public function getYield() : float{ return $this->yield; } /** * Sets the percentage chance of drops from each block destroyed by the explosion. * @param float $yield 0-100 */ public function setYield(float $yield) : void{ if($yield < 0.0 || $yield > 100.0){ throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0"); } $this->yield = $yield; } }