forked from pmmp/PocketMine-MP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace pocketmine\event\block; | ||
|
||
use pocketmine\block\Block; | ||
use pocketmine\item\Item; | ||
|
||
/** | ||
* Called when a block is destroyed because its support has been destroyed. | ||
*/ | ||
class BlockSupportBreakEvent extends BlockEvent{ | ||
/** @var Item[] */ | ||
protected array $blockDrops = []; | ||
|
||
/** | ||
* @param Item[] $drops | ||
*/ | ||
public function __construct( | ||
Block $block, | ||
array $drops = [], | ||
protected int $xpDrops = 0 | ||
){ | ||
parent::__construct($block); | ||
$this->setDrops($drops); | ||
} | ||
|
||
/** | ||
* @return Item[] | ||
*/ | ||
public function getDrops() : array{ | ||
return $this->blockDrops; | ||
} | ||
|
||
/** | ||
* @param Item[] $drops | ||
*/ | ||
public function setDrops(array $drops) : void{ | ||
$this->setDropsVariadic(...$drops); | ||
} | ||
|
||
/** | ||
* Variadic hack for easy array member type enforcement. | ||
*/ | ||
public function setDropsVariadic(Item ...$drops) : void{ | ||
$this->blockDrops = $drops; | ||
} | ||
|
||
/** | ||
* Returns how much XP will be dropped by breaking this block. | ||
*/ | ||
public function getXpDropAmount() : int{ | ||
return $this->xpDrops; | ||
} | ||
|
||
/** | ||
* Sets how much XP will be dropped by breaking this block. | ||
*/ | ||
public function setXpDropAmount(int $amount) : void{ | ||
if($amount < 0){ | ||
throw new \InvalidArgumentException("Amount must be at least zero"); | ||
} | ||
$this->xpDrops = $amount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters