minecraft:behavior.fire_at_target for you with a switch.Get GodCraftOverview
minecraft:behavior.fire_at_target is an entity component: it goes in the components object of a custom mob, or in one of its component groups. AI goal that makes the mob shoot a projectile at its target after a short wind-up, like a breeze. Its anchor and offset settings replace the ones in the projectile.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
filters | Filter Group | {"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null} | Conditions that must pass before the mob shoots. |
attack_range | FloatRange | {"max":0,"min":0} | Closest and farthest the target can be for a shot. |
attack_cooldown | number | 0.5 | Seconds to wait before the goal can run again.Range: 0 to … |
pre_shoot_delay | number | 0.75 | Seconds of wind-up before the shot.Range: 0 to … |
post_shoot_delay | number | 0.2 | Seconds after the shot before the goal ends.Range: 0 to … |
max_head_rotation_x | number | 30 | Most degrees the head can tilt up or down to aim. |
max_head_rotation_y | number | 30 | Most degrees the head can turn sideways to aim. |
ranged_fov | number | 90 | Field of view in degrees used to spot a target. |
projectile_def | string | "" | The entity fired. It must be a projectile, and the goal does nothing without it. |
owner_anchor | ProjectileAnchorProxy | 2 | Point on the shooter where the projectile appears. |
owner_offset | vec3 | [0,0,0] | Shift from the owner_anchor point. |
target_anchor | ProjectileAnchorProxy | 2 | Point on the target that the projectile aims at. |
target_offset | vec3 | [0,0,0] | Shift from the target_anchor point. |
priority | integer | 0 | Lower numbers run first: when two goals compete, the one with the smaller priority wins.Range: 0 to … |
control_flags | Goal's control flags[] | none | Which body parts this goal takes over (move, look, jump), so goals using the same parts cannot run together. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:behavior.fire_at_target": {
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
},
"attack_range": {
"max": 0,
"min": 0
},
"attack_cooldown": 0.5,
"pre_shoot_delay": 0.75,
"post_shoot_delay": 0.2,
"max_head_rotation_x": 30,
"max_head_rotation_y": 30,
"ranged_fov": 90
}
}