mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Added Cactus damage
This commit is contained in:
parent
34139c7efe
commit
8a8a95480e
@ -2348,6 +2348,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EntityDamageEvent::CAUSE_CONTACT:
|
case EntityDamageEvent::CAUSE_CONTACT:
|
||||||
|
$message = $this->getName() . " was pricked to death";
|
||||||
|
break;
|
||||||
|
|
||||||
case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
|
case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
|
||||||
case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
|
case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
|
||||||
case EntityDamageEvent::CAUSE_MAGIC:
|
case EntityDamageEvent::CAUSE_MAGIC:
|
||||||
|
@ -26,6 +26,9 @@ use pocketmine\level\Level;
|
|||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector3 as Vector3;
|
use pocketmine\math\Vector3 as Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
|
use pocketmine\Server;
|
||||||
|
|
||||||
class Cactus extends Transparent{
|
class Cactus extends Transparent{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
@ -45,6 +48,14 @@ class Cactus extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onEntityCollide(Entity $entity){
|
||||||
|
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||||
|
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$entity->attack($ev->getFinalDamage(), $ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
$down = $this->getSide(0);
|
$down = $this->getSide(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user