Moved player attack filter from Living to Player

This commit is contained in:
Shoghi Cervantes 2014-07-13 19:04:00 +02:00
parent 6fbfa1836f
commit eccd82ca4b
2 changed files with 16 additions and 17 deletions

View File

@ -2222,6 +2222,22 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
if($this->dead === true){
return;
}
if(($this->getGamemode() & 0x01) === 1){
if($source instanceof EntityDamageEvent){
$cause = $source->getCause();
}else{
$cause = $source;
}
if(
$cause !== EntityDamageEvent::CAUSE_MAGIC
and $cause !== EntityDamageEvent::CAUSE_SUICIDE
and $cause !== EntityDamageEvent::CAUSE_VOID
){
return;
}
}
$pk = new EntityEventPacket();
$pk->eid = 0;
$pk->event = 2;

View File

@ -59,23 +59,6 @@ abstract class Living extends Entity implements Damageable{
public abstract function getName();
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){
if($this instanceof Player and ($this->getGamemode() & 0x01) === 1){
if($source instanceof EntityDamageEvent){
$cause = $source->getCause();
}else{
$cause = $source;
}
if(
$cause !== EntityDamageEvent::CAUSE_MAGIC
and $cause !== EntityDamageEvent::CAUSE_SUICIDE
and $cause !== EntityDamageEvent::CAUSE_VOID
){
return;
}
}
//TODO: attack tick limit
$pk = new EntityEventPacket();
$pk->eid = $this->getID();