Skip to content

Fix: Zombie Pigmen Creative Agro#1151

Open
jckitkat wants to merge 3 commits intosmartcmd:mainfrom
jckitkat:Zombie-Pigman-Fix
Open

Fix: Zombie Pigmen Creative Agro#1151
jckitkat wants to merge 3 commits intosmartcmd:mainfrom
jckitkat:Zombie-Pigman-Fix

Conversation

@jckitkat
Copy link

@jckitkat jckitkat commented Mar 11, 2026

Description

Fixed issue where zombie pigmen will agro onto a player that is in creative mode.

Previous Behavior

Prior to these changes, zombie pigmen would attempt to attack any player that caused damage, no matter if the offending player was invulnerable or not.

Root Cause

Previously the Entity class had a virtual function called isAttackable that returned true if it was not overwritten by a class extending it. The player class never overwrites this function, and thus, any call to the function simply returns true. The ZombiePig class also never checked this function in its check on whether or not it should agro.

New Behavior

Zombie Pigmen no longer attack a player that is in creative mode.

Fix Implementation

Commit 1: Implemented the isAttackable function in the Player class. The function simply returns the opposite of whether or not the player is invulnerable. Also added this function to the Zombie Pigmen check for whether or not it should agro.

Commit 2: Swapped isAttackable function for isInvulnerable inside Player class and set return value equal to (abilities.invulnerable || hasInvulnerablePrivilege()). Also added same check for the isInvulnerable function to Wolf class to prevent the same issue that zombie pigmen had.

Commit 3: Removed previous change from commit 2 that unnecessarily added check for if the player is invulnerable in the wolf agro checks

Related Issues

@jckitkat jckitkat changed the title Zombie Pigman Creative Agro Fix Fix: Zombie Pigman Creative Agro Mar 11, 2026
@codeHusky
Copy link
Collaborator

This function seems redundant, just use isInvulnerable please

@codeHusky codeHusky marked this pull request as draft March 11, 2026 20:06
@jckitkat jckitkat changed the title Fix: Zombie Pigman Creative Agro Fix: Zombie Pigmen Creative Agro Mar 11, 2026
@jckitkat jckitkat marked this pull request as ready for review March 11, 2026 21:30
@jckitkat jckitkat marked this pull request as draft March 11, 2026 21:30
@jckitkat jckitkat marked this pull request as ready for review March 11, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] zombie pigmans get mad at you in creative

2 participants