PocketMine-MP 5.28.3 git-d5a1007c80fcee27feb2251cf5dcf1ad5a59a85c
Loading...
Searching...
No Matches
BlockExplodeEvent.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
25
28use pocketmine\event\CancellableTrait;
31
37class BlockExplodeEvent extends BlockEvent implements Cancellable{
39
44 public function __construct(
45 Block $block,
46 private Position $position,
47 private array $blocks,
48 private float $yield,
49 private array $ignitions
50 ){
51 parent::__construct($block);
52
53 Utils::checkFloatNotInfOrNaN("yield", $yield);
54 if($yield < 0.0 || $yield > 100.0){
55 throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");
56 }
57 }
58
59 public function getPosition() : Position{
60 return $this->position;
61 }
62
68 public function getYield() : float{
69 return $this->yield;
70 }
71
77 public function setYield(float $yield) : void{
78 Utils::checkFloatNotInfOrNaN("yield", $yield);
79 if($yield < 0.0 || $yield > 100.0){
80 throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");
81 }
82 $this->yield = $yield;
83 }
84
90 public function getAffectedBlocks() : array{
91 return $this->blocks;
92 }
93
99 public function setAffectedBlocks(array $blocks) : void{
100 Utils::validateArrayValueType($blocks, fn(Block $block) => null);
101 $this->blocks = $blocks;
102 }
103
109 public function getIgnitions() : array{
110 return $this->ignitions;
111 }
112
118 public function setIgnitions(array $ignitions) : void{
119 Utils::validateArrayValueType($ignitions, fn(Block $block) => null);
120 $this->ignitions = $ignitions;
121 }
122}
__construct(Block $block, private Position $position, private array $blocks, private float $yield, private array $ignitions)