diff --git a/Minecraft.World/PigZombie.cpp b/Minecraft.World/PigZombie.cpp index 1be123d7a..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) ) + 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 00c7148e4..9e5e08dee 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -195,6 +195,11 @@ bool Player::isUsingItem() return useItem != nullptr; } +bool Player::isInvulnerable() +{ + return abilities.invulnerable || hasInvulnerablePrivilege(); +} + int Player::getTicksUsingItem() { if (isUsingItem()) diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 2e223a1e5..b1a27d270 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -495,6 +495,8 @@ class Player : public LivingEntity, public CommandSender, public ScoreHolder void setPlayerGamePrivilege(EPlayerGamePrivileges privilege, unsigned int value); static void setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGamePrivileges privilege, unsigned int value); + virtual bool isInvulnerable(); + bool isAllowedToUse(Tile *tile); bool isAllowedToUse(shared_ptr item); bool isAllowedToInteract(shared_ptr target);