mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Made ExplosionPrimeEvent accept setting block breaking settings
This commit is contained in:
parent
0dba14074a
commit
0dd46c835c
@ -126,7 +126,11 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
$this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
(new Explosion($this, $ev->getForce(), $this))->explode();
|
||||
$explosion = new Explosion($this, $ev->getForce(), $this);
|
||||
if($ev->isBlockBreaking()){
|
||||
$explosion->explodeA();
|
||||
}
|
||||
$explosion->explodeB();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
protected $force;
|
||||
private $blockBreaking;
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
@ -39,6 +40,7 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
public function __construct(Entity $entity, $force){
|
||||
$this->entity = $entity;
|
||||
$this->force = $force;
|
||||
$this->blockBreaking = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,4 +54,18 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
$this->force = (float) $force;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBlockBreaking(){
|
||||
return $this->blockBreaking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $affectsBlocks
|
||||
*/
|
||||
public function setBlockBreaking($affectsBlocks){
|
||||
$this->blockBreaking = (bool) $affectsBlocks;
|
||||
}
|
||||
|
||||
}
|
@ -64,9 +64,21 @@ class Explosion{
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return bool
|
||||
*/
|
||||
public function explode(){
|
||||
if($this->explodeA()){
|
||||
return $this->explodeB();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function explodeA(){
|
||||
if($this->size < 0.1){
|
||||
return false;
|
||||
}
|
||||
@ -108,6 +120,10 @@ class Explosion{
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function explodeB(){
|
||||
$send = [];
|
||||
$source = $this->source->floor();
|
||||
$yield = (1 / $this->size) * 100;
|
||||
@ -204,6 +220,5 @@ class Explosion{
|
||||
Server::broadcastPacket($this->level->getUsingChunk($source->x >> 4, $source->z >> 4), $pk);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user