diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ac4099c89ed..d172fdef785 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2348,6 +2348,9 @@ public function kill(){ break; case EntityDamageEvent::CAUSE_CONTACT: + $message = $this->getName() . " was pricked to death"; + break; + case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION: case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION: case EntityDamageEvent::CAUSE_MAGIC: diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index 98ef2e61b0e..d551767cce0 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -26,6 +26,9 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3 as Vector3; use pocketmine\Player; +use pocketmine\entity\Entity; +use pocketmine\event\entity\EntityDamageEvent; +use pocketmine\Server; class Cactus extends Transparent{ public function __construct($meta = 0){ @@ -45,6 +48,14 @@ public function getBoundingBox(){ ); } + 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){ if($type === Level::BLOCK_UPDATE_NORMAL){ $down = $this->getSide(0);