Only reduce durability when armor reduced damage. (#5444)

https://minecraft.fandom.com/wiki/Durability#Armor_durability
This commit is contained in:
Rush2929 2022-12-06 06:10:36 +09:00 committed by GitHub
parent 174c9a48f5
commit 1d4b6dc66e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -455,7 +455,9 @@ abstract class Living extends Entity{
*/
protected function applyPostDamageEffects(EntityDamageEvent $source) : void{
$this->setAbsorption(max(0, $this->getAbsorption() + $source->getModifier(EntityDamageEvent::MODIFIER_ABSORPTION)));
$this->damageArmor($source->getBaseDamage());
if($source->canBeReducedByArmor()){
$this->damageArmor($source->getBaseDamage());
}
if($source instanceof EntityDamageByEntityEvent && ($attacker = $source->getDamager()) !== null){
$damage = 0;