PaperMC / PaperMC/Paper

Missing API for accessing targets of mobs using new AI brain system

Open
#6,862 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #5605 by @Machine-Maker — closed without merging
status: accepted type: bug version: 1.17
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Expected behavior

That getTarget() returns the entity the axolotl is currently targeting, and that setTarget(null) clears targeting.

Observed/Actual behavior

getTarget() returns null, even when the axolotl is attacking another entity. Setting the target to null also does nothing.

Steps/models to reproduce

Reproduced this using the following code:

@EventHandler
    public void onAxolotlAttack(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Axolotl axolotl) {
            if (axolotl.getTarget() != null)
                getLogger().info(String.format("Target type: %s", axolotl.getTarget().getType().name()));
            else
                getLogger().info("Target is null");

            axolotl.setTarget(null);
        }
    }

The output will be the "Target is null" message each time, and the axolotl continues attacking.

Plugin and Datapack List

Plugins (1): TestPlugin

There are 2 data packs enabled: [vanilla (built-in)], [file/bukkit (world)]
There are no more data packs available

Paper version

This server is running Paper version git-Paper-359 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: bc43f40)
You are running the latest version

Other

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided Axolotl event-handler snippet, then inspect the mob target API and the new AI brain system. Done means getTarget() returns the entity currently being attacked and setTarget(null) clears targeting, as described in the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.