mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Moved player attack filter from Living to Player
This commit is contained in:
parent
6fbfa1836f
commit
eccd82ca4b
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user