Ambiguity in Mob.getTarget() functionality
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
While player is tempting animal with food.
Cow cow = EntityMoveEvent.getEntity(); <-- animal
cow.getTarget() <--- returns Player object of player that's doing the tempting
Observed/Actual behavior
cow.getTarget(); is not a Player object
but EntityTargetLivingEntityEvent.getTarget() correctly returns a targeting player
I'm guessing this is due to my observation, which is that cow re-targets the player every two ticks or so.
Steps/models to reproduce
- Use MWE plugin: https://github.com/kacpermajkowski/AnimalTargetIssueMWE
- Use commands on the server:
- /gamerule spawn_mobs false
- /gamerule spawn_monsters false
- (multiple times if needed, to be sure no other cows are present) /minecraft:kill @e
- Spawn a Cow
- Take wheat in your hand and make the Cow follow you
- What you see is that checking Mob.getTarget() in EntityMoveEvent returns a non-Player object, and at the same time EntityTargetLivingEntityEvent.getTarget() returns a Player object.
Plugin and Datapack List
[21:40:30 INFO]: ℹ Server Plugins (7):
[21:40:30 INFO]: Paper Plugins (1):
[21:40:30 INFO]: - AnimalTargetIssueMWE
[21:40:30 INFO]: Bukkit Plugins (6):
[21:40:30 INFO]: - ConfigLib, Essentials, EssentialsChat, EssentialsSpawn, HeadDB, Vault
datapack list
[21:40:41 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[21:40:41 INFO]: There are no more data packs available
Paper version
[21:40:49 INFO]: Checking version, please wait...
[21:40:49 INFO]: This server is running Paper version 26.2-26-dev/26.2@193803d (2026-06-21T04:21:03Z) (Implementing API version 26.2.build.26-alpha)
You are 3 version(s) behind
Download the new version at: https://papermc.io/downloads/paper
Previous version: 26.1.2-72-1a6b910 (MC: 26.1.2)
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked AnimalTargetIssueMWE with the listed commands and compare Mob.getTarget() in EntityMoveEvent with EntityTargetLivingEntityEvent.getTarget(). Trace the Paper API and entity-target update path to determine which target state each event exposes. Done means the behavior is consistent with the documented contract, or the differing timing and expected usage are clearly documented and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100