mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Added ExplosionPrimeEvent
This commit is contained in:
parent
64bf293c69
commit
57f7d57c76
@ -23,6 +23,8 @@ namespace pocketmine\entity;
|
||||
|
||||
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\entity\ExplosionPrimeEvent;
|
||||
use pocketmine\level\Explosion;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\String;
|
||||
@ -116,12 +118,16 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
|
||||
}
|
||||
|
||||
public function heal($amount){
|
||||
public function heal($amount, $source = EntityRegainHealthEvent::CAUSE_MAGIC){
|
||||
|
||||
}
|
||||
|
||||
public function explode(){
|
||||
(new Explosion($this, 4, $this))->explode();
|
||||
$this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
(new Explosion($this, $ev->getForce(), $this))->explode();
|
||||
}
|
||||
}
|
||||
|
||||
public function spawnTo(Player $player){
|
||||
|
57
src/pocketmine/event/entity/ExplosionPrimeEvent.php
Normal file
57
src/pocketmine/event/entity/ExplosionPrimeEvent.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\entity;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\level\Position;
|
||||
|
||||
/**
|
||||
* Called when a entity decides to explode
|
||||
*/
|
||||
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
protected $force;
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
* @param float $force
|
||||
*/
|
||||
public function __construct(Entity $entity, $force){
|
||||
$this->entity = $entity;
|
||||
$this->force = $force;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getForce(){
|
||||
return $this->force;
|
||||
}
|
||||
|
||||
public function setForce($force){
|
||||
$this->force = (float) $force;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user