Merge branch 'release/3.0' into release/3.1

This commit is contained in:
Dylan K. Taylor 2018-06-22 17:47:33 +01:00
commit 4c9ca53b32
2 changed files with 12 additions and 8 deletions

View File

@ -2529,11 +2529,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
}
if($heldItem->onAttackEntity($target) and $this->isSurvival()){ //always fire the hook, even if we are survival
$this->inventory->setItemInHand($heldItem);
}
if($this->isAlive()){
//reactive damage like thorns might cause us to be killed by attacking another mob, which
//would mean we'd already have dropped the inventory by the time we reached here
if($heldItem->onAttackEntity($target) and $this->isSurvival()){ //always fire the hook, even if we are survival
$this->inventory->setItemInHand($heldItem);
}
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
}
return true;
default:

View File

@ -469,6 +469,7 @@ abstract class Living extends Entity implements Damageable{
/**
* Called after EntityDamageEvent execution to apply post-hurt effects, such as reducing absorption or modifying
* armour durability.
* This will not be called by damage sources causing death.
*
* @param EntityDamageEvent $source
*/
@ -534,6 +535,8 @@ abstract class Living extends Entity implements Damageable{
return;
}
$this->attackTime = 10; //0.5 seconds cooldown
if($source instanceof EntityDamageByEntityEvent){
$e = $source->getDamager();
if($source instanceof EntityDamageByChildEntityEvent){
@ -551,15 +554,12 @@ abstract class Living extends Entity implements Damageable{
}
}
$this->applyPostDamageEffects($source);
if($this->isAlive()){
$this->applyPostDamageEffects($source);
$this->doHitAnimation();
}else{
$this->startDeathAnimation();
}
$this->attackTime = 10; //0.5 seconds cooldown
}
protected function doHitAnimation() : void{