This commit is contained in:
jckitkat 2026-04-22 06:00:45 +03:00 committed by GitHub
commit 241f022ee2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -105,7 +105,7 @@ shared_ptr<Entity> PigZombie::findAttackTarget()
bool PigZombie::hurt(DamageSource *source, float dmg)
{
shared_ptr<Entity> sourceEntity = source->getEntity();
if ( sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER) )
if ( sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER) && !sourceEntity->isInvulnerable())
{
vector<shared_ptr<Entity> > *nearby = level->getEntities( shared_from_this(), bb->grow(32, 32, 32));
for (auto& e : *nearby)

View file

@ -195,6 +195,11 @@ bool Player::isUsingItem()
return useItem != nullptr;
}
bool Player::isInvulnerable()
{
return abilities.invulnerable || hasInvulnerablePrivilege();
}
int Player::getTicksUsingItem()
{
if (isUsingItem())

View file

@ -495,6 +495,8 @@ public:
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<ItemInstance> item);
bool isAllowedToInteract(shared_ptr<Entity> target);