Improve documentation of ExplosionPrimeEvent and EntityExplodeEvent

This commit is contained in:
Dylan K. Taylor 2022-05-21 23:00:34 +01:00
parent afc6e8878d
commit 3dd7c09351
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 24 additions and 3 deletions

View File

@ -31,7 +31,11 @@ use pocketmine\utils\Utils;
use pocketmine\world\Position; use pocketmine\world\Position;
/** /**
* Called when a entity explodes * Called when an entity explodes, after the explosion's impact has been calculated.
* No changes have been made to the world at this stage.
*
* @see ExplosionPrimeEvent
*
* @phpstan-extends EntityEvent<Entity> * @phpstan-extends EntityEvent<Entity>
*/ */
class EntityExplodeEvent extends EntityEvent implements Cancellable{ class EntityExplodeEvent extends EntityEvent implements Cancellable{
@ -48,6 +52,7 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
/** /**
* @param Block[] $blocks * @param Block[] $blocks
* @param float $yield 0-100
*/ */
public function __construct(Entity $entity, Position $position, array $blocks, float $yield){ public function __construct(Entity $entity, Position $position, array $blocks, float $yield){
$this->entity = $entity; $this->entity = $entity;
@ -64,6 +69,8 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
} }
/** /**
* Returns a list of blocks destroyed by the explosion.
*
* @return Block[] * @return Block[]
*/ */
public function getBlockList() : array{ public function getBlockList() : array{
@ -71,6 +78,8 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
} }
/** /**
* Sets the blocks destroyed by the explosion.
*
* @param Block[] $blocks * @param Block[] $blocks
*/ */
public function setBlockList(array $blocks) : void{ public function setBlockList(array $blocks) : void{
@ -78,10 +87,18 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
$this->blocks = $blocks; $this->blocks = $blocks;
} }
/**
* Returns the percentage chance of drops from each block destroyed by the explosion.
* @return float 0-100
*/
public function getYield() : float{ public function getYield() : float{
return $this->yield; 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{ public function setYield(float $yield) : void{
if($yield < 0.0 || $yield > 100.0){ if($yield < 0.0 || $yield > 100.0){
throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0"); throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");

View File

@ -28,7 +28,11 @@ use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait; use pocketmine\event\CancellableTrait;
/** /**
* Called when a entity decides to explode * Called when an entity decides to explode, before the explosion's impact is calculated.
* This allows changing the force of the explosion and whether it will destroy blocks.
*
* @see EntityExplodeEvent
*
* @phpstan-extends EntityEvent<Entity> * @phpstan-extends EntityEvent<Entity>
*/ */
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{