Denizen Script Mechanisms


Mechanisms are found in object properties, the 'adjust' command, and similar. These are used to change the state of an object.
Learn about how mechanisms work in The Beginner's Guide.


Showing 1 out of 678 mechanisms...
Nameadd_target_goal
ObjectEntityTag
InputMapTag
Related Tags<EntityTag.target_goals> Returns the target goals that were added to a mob by Mechanism:EntityTag.add_target_goal, as a map of goal ID to a map of its settings: (...)
DescriptionGives a mob a target-finding AI goal: the mob will look for nearby living entities that match a given matcher and attack the nearest one,
in the same way that vanilla hostile mobs look for players.
This makes the mob natively hostile to those entities - it finds, chases, attacks, and forgets them through its normal AI, with no need for a script to keep assigning targets.

Input is a map with:
"matcher": required, an entity matcher (as in ObjectType:EntityTag) for the entities to target, such as "mannequin" or "entity_flagged:my_flag".
"id": optional, a name for this goal, made of lowercase letters, digits, underscores, hyphens and dots. Defaults to "default". Adding a goal with an ID the mob already has replaces the old one.
"priority": optional, the priority of the goal among the mob's target goals. Defaults to 3.
A lower number is a higher priority: a goal can interrupt running goals with a higher number, and cannot start while a goal with the same or a lower number is running.
For reference, most vanilla hostile mobs look for players at priority 2 and retaliate against attackers at priority 1, so the default of 3 makes the mob prefer real players.
"range": optional, how far away (in blocks) the mob can find and keep a target. Defaults to 16.
"must_see": optional, whether the mob needs line of sight to find a target, and gives up after about 3 seconds without it. Defaults to true.

The mob never targets invulnerable entities or players in creative or spectator mode, and leaves alone a target that a script or another plugin has set directly (such as via Command:attack).
This only works for mobs that pick targets through AI goals, like zombies, skeletons, spiders, and creepers.
Mobs driven by a brain instead, like piglins, hoglins, and wardens, are not affected.

Goals are not saved with the entity: they are lost when the entity is unloaded, so they should be added whenever it enters the world, as in the example.
Example
# Makes every monster natively hostile to mannequins flagged 'offline_body'.
on monster added to world:
- adjust <context.entity> add_target_goal:[matcher=entity_flagged:offline_body]
Example
# Makes the zombie prefer mannequins over players, at up to 24 blocks, even through walls.
- adjust <[zombie]> add_target_goal:[id=mannequins;matcher=mannequin;priority=1;range=24;must_see=false]
Grouppaper
RequiresPaper
Sourcehttps://github.com/MINEZ/Denizen/blob/dev/paper/src/main/java/com/denizenscript/denizen/paper/properties/PaperEntityExtensions.java#L260