Improved damage sources for projectiles, falling blocks, TNT, and items

This commit is contained in:
Shoghi Cervantes 2015-05-31 14:19:47 +02:00
parent 9e14435dbb
commit 14ff537e71
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
4 changed files with 20 additions and 4 deletions

View File

@ -78,7 +78,9 @@ class FallingSand extends Entity{
}
public function attack($damage, EntityDamageEvent $source){
if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
parent::attack($damage, $source);
}
}
public function onUpdate($currentTick){

View File

@ -75,6 +75,17 @@ class Item extends Entity{
$this->server->getPluginManager()->callEvent(new ItemSpawnEvent($this));
}
public function attack($damage, EntityDamageEvent $source){
if(
$source->getCause() === EntityDamageEvent::CAUSE_VOID or
$source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK or
$source->getCause() === EntityDamageEvent::CAUSE_ENTITY_EXPLOSION or
$source->getCause() === EntityDamageEvent::CAUSE_BLOCK_EXPLOSION
){
parent::attack($damage, $source);
}
}
public function onUpdate($currentTick){
if($this->closed){
return false;

View File

@ -47,7 +47,9 @@ class PrimedTNT extends Entity implements Explosive{
public function attack($damage, EntityDamageEvent $source){
if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
parent::attack($damage, $source);
}
}
protected function initEntity(){

View File

@ -52,9 +52,10 @@ abstract class Projectile extends Entity{
parent::__construct($chunk, $nbt);
}
public function attack($damage, EntityDamageEvent $source){
if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
parent::attack($damage, $source);
}
}
protected function initEntity(){