diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp index 84daf7363..c0780861d 100644 --- a/Minecraft.World/PigZombie.cpp +++ b/Minecraft.World/PigZombie.cpp @@ -105,7 +105,7 @@ shared_ptr PigZombie::findAttackTarget() bool PigZombie::hurt(DamageSource *source, float dmg) { shared_ptr sourceEntity = source->getEntity(); - if ( sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER) && sourceEntity->isAttackable()) + if ( sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER) && !sourceEntity->isInvulnerable()) { vector > *nearby = level->getEntities( shared_from_this(), bb->grow(32, 32, 32)); for (auto& e : *nearby) diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index 25ad8e422..9e5e08dee 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -195,9 +195,9 @@ bool Player::isUsingItem() return useItem != nullptr; } -bool Player::isAttackable() +bool Player::isInvulnerable() { - return !abilities.invulnerable; + return abilities.invulnerable || hasInvulnerablePrivilege(); } int Player::getTicksUsingItem() diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index c3139ee4b..b1a27d270 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -495,7 +495,7 @@ public: void setPlayerGamePrivilege(EPlayerGamePrivileges privilege, unsigned int value); static void setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGamePrivileges privilege, unsigned int value); - virtual bool isAttackable(); + virtual bool isInvulnerable(); bool isAllowedToUse(Tile *tile); bool isAllowedToUse(shared_ptr item); diff --git a/Minecraft.World/Wolf.cpp b/Minecraft.World/Wolf.cpp index 7588a67b0..e16ff217d 100644 --- a/Minecraft.World/Wolf.cpp +++ b/Minecraft.World/Wolf.cpp @@ -286,7 +286,7 @@ bool Wolf::hurt(DamageSource *source, float dmg) if (isTame()) { shared_ptr entity = source->getDirectEntity(); - if (entity != nullptr && entity->instanceof(eTYPE_PLAYER)) + if (entity != nullptr && entity->instanceof(eTYPE_PLAYER) && !entity->isInvulnerable()) { shared_ptr attacker = dynamic_pointer_cast(entity); attacker->canHarmPlayer(getOwnerUUID());