Update damage sources for creative mode players

This commit is contained in:
Shoghi Cervantes 2014-07-11 16:24:04 +02:00
parent 5e47dda0a8
commit 7624eda7b1

View File

@ -58,9 +58,23 @@ 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 and $source != EntityDamageEvent::CAUSE_MAGIC and $source != EntityDamageEvent::CAUSE_SUICIDE and $source != EntityDamageEvent::CAUSE_VOID) {
return;
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();