[GH-ISSUE #7417] Native mods: add and remove AI goals on mobs (GoalSelector.addGoal / removeGoal) #3231

Open
opened 2026-11-03 04:06:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Qwerner88880 on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7417

Originally assigned to: @Qwerner88880 on GitHub.

🤖 Filed by Qwerner88880's AI agent (Claude Code, Claude Opus 5.5), not by Qwerner88880 personally.

Part of #4953 (it has no line for this yet).

The gap

Horizon has vanilla's GoalSelector, with priorities, the MOVE/LOOK/JUMP/TARGET flags, interruption and the shared goals (crates/horizon-client/src/mobs/goals.rs). A native mod can't add a goal to a mob or remove one. NeoForge mods do this in EntityJoinLevelEvent, through mob.goalSelector.addGoal / targetSelector.addGoal and removeGoal, both for their own mobs and to change vanilla's: a boss's attack phases, a pet that follows a block, mobs that avoid a mod's block.

The mob-griefing line in #4953 is blocked for a related reason: the AI reads the world from a per-tick snapshot, so a mod can't be asked in the middle of a goal. This issue is the general path.

Proposal

  • A mod goal registered by id, with the Goal contract: flags, can_use, can_continue, start, stop, tick and every_tick. It is dispatched to the owning mod through a hook (native_mob_goal(goal_id, phase, mob, &mut verdict)). It sees the mob through the existing mob helpers, and it moves and targets the mob through MobEvents, like the vanilla goals do.
  • Helpers to add a mod goal or a vanilla goal at a priority, and to remove goals by name, on the goal or target selector. They can be called from entity_join_level and mob_spawned.
  • Goals are added again on load, as in vanilla. Nothing new is saved.

Steps, each its own PR under 500 lines: removing and re-prioritising vanilla goals; a mod goal on the goal selector; a mod goal on the target selector.

Coordination

This works on any mob, including a content mod's own entity types once #5212 (reservedbytes) covers mobs. It doesn't touch entity type registration.

Originally created by @Qwerner88880 on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7417 Originally assigned to: @Qwerner88880 on GitHub. > 🤖 Filed by Qwerner88880's AI agent (Claude Code, Claude Opus 5.5), not by Qwerner88880 personally. Part of #4953 (it has no line for this yet). ## The gap Horizon has vanilla's `GoalSelector`, with priorities, the MOVE/LOOK/JUMP/TARGET flags, interruption and the shared goals (`crates/horizon-client/src/mobs/goals.rs`). A native mod can't add a goal to a mob or remove one. NeoForge mods do this in `EntityJoinLevelEvent`, through `mob.goalSelector.addGoal` / `targetSelector.addGoal` and `removeGoal`, both for their own mobs and to change vanilla's: a boss's attack phases, a pet that follows a block, mobs that avoid a mod's block. The mob-griefing line in #4953 is blocked for a related reason: the AI reads the world from a per-tick snapshot, so a mod can't be asked in the middle of a goal. This issue is the general path. ## Proposal - A mod goal registered by id, with the `Goal` contract: `flags`, `can_use`, `can_continue`, `start`, `stop`, `tick` and `every_tick`. It is dispatched to the owning mod through a hook (`native_mob_goal(goal_id, phase, mob, &mut verdict)`). It sees the mob through the existing mob helpers, and it moves and targets the mob through `MobEvent`s, like the vanilla goals do. - Helpers to add a mod goal or a vanilla goal at a priority, and to remove goals by name, on the goal or target selector. They can be called from `entity_join_level` and `mob_spawned`. - Goals are added again on load, as in vanilla. Nothing new is saved. Steps, each its own PR under 500 lines: removing and re-prioritising vanilla goals; a mod goal on the goal selector; a mod goal on the target selector. ## Coordination This works on any mob, including a content mod's own entity types once #5212 (reservedbytes) covers mobs. It doesn't touch entity type registration.
Author
Owner

@Qwerner88880 commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6581294792 --> @Qwerner88880 commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3231
No description provided.