Added Cactus damage

This commit is contained in:
Shoghi Cervantes 2014-09-16 12:02:18 +02:00
parent 34139c7efe
commit 8a8a95480e
2 changed files with 14 additions and 0 deletions

View File

@ -2348,6 +2348,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
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:

View File

@ -26,6 +26,9 @@ use pocketmine\level\Level;
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 @@ 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){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);