[SPIGOT-7112] Mobs Added 1.17 and After Do Not Create an EntityTargetEvent Properly Created: 22/Jul/22  Updated: 25/Dec/24  Resolved: 16/Aug/22

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: RT5Phantom Assignee: Doc
Resolution: Fixed Votes: 0
Labels: 1.17, 1.18, 1.19, API, EntityTargetEvent, Spigot
Environment:

Tested on the latest version of Vanilla Spigot, as well as some past major versions of Spigot Minecraft that I already had on my computer


Attachments: File entitytargetevent-1.0-SNAPSHOT.jar     PNG File image-2022-07-22-09-50-57-916.png     PNG File image-2022-07-22-09-51-08-841.png    
Issue Links:
Relates
relates to SPIGOT-7079 Allays don't call EntityTargetEvent o... Resolved
Version: CraftBukkit version 3552-Spigot-14a2382-fc30711 (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

I've been working with the EntityTargetEvent to run code when specific mobs try to target a player who has food in their hand. I have found that the EntityTargetEvent works as expected, except for mobs which have been added to Minecraft during and after version 1.17. In this case, the mobs will not create a targeting event and continue as normal, which stops me from modifying vanilla behavior. Other ways of targeting appear to work (EG: a goat targeting an entity to ram them). I have tested this in a few versions of Spigot and Minecraft and it seems to be occurring since Spigot builds for Minecraft 1.17.

 

Me holding wheat and being targeted by a cow, sheep, and goat

 

My console during this point in time - only the cow and sheep create an event not the goat

 

From my testing, this occurs with every mob added during and after 1.17. that will follow a player because they are holding food. This includes axolotls, frogs, and goats.

I also found the following from testing which I believe could also be part of this issue:

  • An event is not created for when Allays seek to track a player down and give them an item. 
  • An event is not created when a non-angered warden begins to follow a player. It is only created when they actively target the player to attack

 

I have included a plugin that I created to test the range of this bug. It simply prints to the console when an entity attempts to target another entity.



 Comments   
Comment by Doc [ 24/Jul/22 ]

Ok about the issue...

  • The Allay when track a player has a issue open (SPIGOT-7079) with a PR waiting for it.
  • About the mobs added since 1.17 i check and exists cases for a few mobs where the food works like "temptation" for follow and this is currently not handled by the EntityTargetEvent also i found exists another case where this can be called and its when baby mobs follow adults like in raids.. i make a different PR for handle the cases i found https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1088/overview
Generated at Wed Apr 02 10:20:38 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.