mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 19:24:12 +00:00
@ -58,7 +58,7 @@ class Explosion{
|
||||
|
||||
public function __construct(
|
||||
public Position $source,
|
||||
public float $size,
|
||||
public float $radius,
|
||||
private Entity|Block|null $what = null
|
||||
){
|
||||
if(!$this->source->isValid()){
|
||||
@ -66,8 +66,8 @@ class Explosion{
|
||||
}
|
||||
$this->world = $this->source->getWorld();
|
||||
|
||||
if($size <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $size");
|
||||
if($radius <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $radius");
|
||||
}
|
||||
$this->subChunkExplorer = new SubChunkExplorer($this->world);
|
||||
}
|
||||
@ -77,7 +77,7 @@ class Explosion{
|
||||
* will be destroyed.
|
||||
*/
|
||||
public function explodeA() : bool{
|
||||
if($this->size < 0.1){
|
||||
if($this->radius < 0.1){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class Explosion{
|
||||
$pointerY = $this->source->y;
|
||||
$pointerZ = $this->source->z;
|
||||
|
||||
for($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){
|
||||
for($blastForce = $this->radius * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){
|
||||
$x = (int) $pointerX;
|
||||
$y = (int) $pointerY;
|
||||
$z = (int) $pointerZ;
|
||||
@ -142,7 +142,7 @@ class Explosion{
|
||||
*/
|
||||
public function explodeB() : bool{
|
||||
$source = (new Vector3($this->source->x, $this->source->y, $this->source->z))->floor();
|
||||
$yield = min(100, (1 / $this->size) * 100);
|
||||
$yield = min(100, (1 / $this->radius) * 100);
|
||||
|
||||
if($this->what instanceof Entity){
|
||||
$ev = new EntityExplodeEvent($this->what, $this->source, $this->affectedBlocks, $yield);
|
||||
@ -155,7 +155,7 @@ class Explosion{
|
||||
}
|
||||
}
|
||||
|
||||
$explosionSize = $this->size * 2;
|
||||
$explosionSize = $this->radius * 2;
|
||||
$minX = (int) floor($this->source->x - $explosionSize - 1);
|
||||
$maxX = (int) ceil($this->source->x + $explosionSize + 1);
|
||||
$minY = (int) floor($this->source->y - $explosionSize - 1);
|
||||
|
Reference in New Issue
Block a user