Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent axolotls from targeting protected mobs #6140

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

Akiranya
Copy link

@Akiranya Akiranya commented Aug 30, 2022

Description:

Previously, axolotl would keep attacking the protected mobs by Towny within a town (so it looks like it's trying to keep attacking but no damage, forever). This PR additionally listens to the EntityTargetLivingEntityEvent, where it uses the original logic to check if the Axolotl is able to damage the defender. If it is not, then cancel the EntityTargetLivingEntityEvent and let the axolotl have its has_hunting_cooldown on (see here for this entity data).

I think this PR improves the code efficiency a bit because if the has_hunting_cooldown is on then axolotls won't having any attacking behaviour for at least 2 min. So neither EntityTargetLivingEntityEvent nor EntityDamageEvent will be called.
Previously, the axolotls would just keep attack the protected mobs and would never have has_hunting_cooldown on since protected mobs can't be killed..

The commits might be a bit of messy but the final changes are just a few lines of code.


New Nodes/Commands/ConfigOptions:

None


Relevant Towny Issue ticket:

None, but I have asked a simple question on the discord related to this PR. Then I took a look at the code and found there was a TODO: Axolotl#setTarget(null) is not actually working. So I basically finished that TODO in this PR :)


  • [x ] I have tested this pull request for defects on a server.

By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the Towny License for perpetuity.

@LlmDl
Copy link
Member

LlmDl commented Aug 30, 2022

I concur with Warrior, there are a lot of unneeded diffs in this PR which will have to be removed. Lots of the changes to CombatUtil that aren't relevant to Axolotls could/should probably be done in a separate PR.

@Akiranya
Copy link
Author

Thanks for the review and suggestions! I've cleaned my commit history so the commits are much cleaner now 👯

@Akiranya
Copy link
Author

Opps I forget the 1.17 back compability. A new commit will be up soon

@LlmDl LlmDl merged commit 75511f1 into TownyAdvanced:master Aug 30, 2022
LlmDl added a commit that referenced this pull request Aug 30, 2022
@LlmDl LlmDl added this to the 0.98.4.0 milestone Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants