Open
Conversation
Collaborator
|
This function seems redundant, just use isInvulnerable please |
…lass; Also added isInvulnerable check to wolf agro function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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