PaperMC / PaperMC/Paper

Expose Vanilla mob goal creation in the API

Open
#12,942 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Is your feature request related to a problem?

I have never used the Mob Goal API before, and I wanted to convert a plugin, which used NMS to achieve this, to the API. In the plugin, there following code was present:

// 'this' is a nms Wolf.
this.goalSelector.addGoal(1, new FloatGoal(this));
this.goalSelector.addGoal(2, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.4D, 3.0F, 1.5F));

So I went ahead, found myself the VanillaGoal interface, and wanted to start with a float goal... and.... nothing. Apparently you cannot create Vanilla goals, only remove or get them from mobs.

Describe the solution you'd like.

I would like the Mob Goal API to be expanded to properly to support creating a Goal<A> from a VanillaGoal<A>.
This could look like this:

Wolf wolf = ...;

Goal<Wolf> floatGoal = VanillaGoal.FLOAT.create(wolf); // This goal has no parameters, so you can just create it.
Goal<Wolf> followOwnerGoal = VanillaGoal.FOLLOW_OWNER.builder(wolf) // Goals which need extra parameters would have a builder.
    .speedModifier(1.4)
    .startDistance(3.0f)
    .stopDistance(1.5f)
    .build();
Goal<Wolf> lookAtPlayerGoal = VanillaGoal.LOOK_AT_PLAYER.builder(wolf)
    .lookAtType(Player.class)
    .lookDistance(8.0f)
    .build();
Describe alternatives you've considered.

With the use of NMS.

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 locating the VanillaGoal interface and its existing get/remove API, then compare those entry points with the Java goal examples in the issue. The work is done when the API supports creating both parameterless and parameterized vanilla goals, with the proposed behavior or an agreed alternative documented by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.