Skip to content

Commit

Permalink
Added Cactus damage
Browse files Browse the repository at this point in the history
  • Loading branch information
shoghicp committed Sep 16, 2014
1 parent 34139c7 commit 8a8a954
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions src/pocketmine/block/Cactus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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);
Expand Down

0 comments on commit 8a8a954

Please sign in to comment.