Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Minecraft.World/PigZombie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Minecraft.World/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ bool Player::isUsingItem()
return useItem != nullptr;
}

bool Player::isInvulnerable()
{
return abilities.invulnerable || hasInvulnerablePrivilege();
}

int Player::getTicksUsingItem()
{
if (isUsingItem())
Expand Down
2 changes: 2 additions & 0 deletions Minecraft.World/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemInstance> item);
bool isAllowedToInteract(shared_ptr<Entity> target);
Expand Down
Loading