File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2348,6 +2348,9 @@ public function kill(){
23482348 break ;
23492349
23502350 case EntityDamageEvent::CAUSE_CONTACT :
2351+ $ message = $ this ->getName () . " was pricked to death " ;
2352+ break ;
2353+
23512354 case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION :
23522355 case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION :
23532356 case EntityDamageEvent::CAUSE_MAGIC :
Original file line number Diff line number Diff line change 2626use pocketmine \math \AxisAlignedBB ;
2727use pocketmine \math \Vector3 as Vector3 ;
2828use pocketmine \Player ;
29+ use pocketmine \entity \Entity ;
30+ use pocketmine \event \entity \EntityDamageEvent ;
31+ use pocketmine \Server ;
2932
3033class Cactus extends Transparent{
3134 public function __construct ($ meta = 0 ){
@@ -45,6 +48,14 @@ public function getBoundingBox(){
4548 );
4649 }
4750
51+ public function onEntityCollide (Entity $ entity ){
52+ $ ev = new EntityDamageEvent ($ entity , EntityDamageEvent::CAUSE_CONTACT , 1 );
53+ Server::getInstance ()->getPluginManager ()->callEvent ($ ev );
54+ if (!$ ev ->isCancelled ()){
55+ $ entity ->attack ($ ev ->getFinalDamage (), $ ev );
56+ }
57+ }
58+
4859 public function onUpdate ($ type ){
4960 if ($ type === Level::BLOCK_UPDATE_NORMAL ){
5061 $ down = $ this ->getSide (0 );
You can’t perform that action at this time.
0 commit comments