minecraft:behavior.ranged_attack
Allows an entity to attack by using ranged shots. "charge_shoot_trigger" must be greater than 0 to enable charged up burst-shot attacks. Requires minecraft:shooter to define projectile behaviour.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
burst_shots | Integer | 1 | Number of shots fired every time the attacking entity uses a charged up attack. |
target_in_sight_time | Decimal | 1 | Minimum amount of time (in seconds) the attacking entity needs to see the target before moving toward it. |
burst_interval | Decimal | 0 | Time (in seconds) between each individual shot when firing a burst of shots from a charged up attack. |
charge_charged_trigger | Decimal | 0 | Time (in seconds, then add "charge_shoot_trigger"), before a charged up attack is done charging. Charge-time decays while target is not in sight. |
charge_shoot_trigger | Decimal | 0 | Amount of time (in seconds, then doubled) a charged shot must be charging before reloading burst shots. Charge-time decays while target is not in sight. |
attack_interval | Object | {"max": -1, "min": -1} | Reload-time range (in seconds), when not using a charged shot. Reload-time range scales with target-distance. |
min | Decimal | 0 | |
max | Decimal | 0 | |
attack_range | Object | {"max": 0, "min": 0} | Range of distances from the target within which the entity can perform a ranged attack. |
min | Decimal | 0 | |
max | Decimal | 0 | |
x_max_rotation | Decimalmin 0 | 30 | Maximum rotation (in degrees), on the X-axis, this entity can rotate while trying to look at the target. |
y_max_head_rotation | Decimalmin 0 | 30 | Maximum rotation (in degrees), on the Y-axis, this entity can rotate its head while trying to look at the target. |
ranged_fov | Decimalmin 0 | 90 | Field of view (in degrees) when using sensing to detect a target for attack. |
speed_multiplier | Decimal | 1 | During attack behavior, this multiplier modifies the entity's speed when moving toward the target. |
set_persistent | Boolean | false | Allows the actor to be set to persist upon targeting a player |
swing | Boolean | false | If a swing animation (using variable.attack_time) exists, this causes the actor to swing their arm(s) upon firing the ranged attack. |
in_range_movement_mode | Texthold_position, follow_target | "hold_position" | Controls how the entity moves while its target is within the configured attack range. "hold_position" makes the entity stop and hold its position while facing and attacking the target. "follow_target" makes the entity continue moving toward the target while attacking, stopping just outside the minimum attack range. |
priority | Integermin 0 | 0 | |
control_flags | List of text | [] |
Example from the game files
This is how vanilla Blaze uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:behavior.ranged_attack": {
"charge_shoot_trigger": 4.0,
"attack_interval": {
"min": 3.0,
"max": 5.0
},
"attack_range": {
"min": 0.0,
"max": 48.0
},
"burst_interval": 0.3,
"burst_shots": 3,
"priority": 3
}
}Used by 14
Vanilla entities with minecraft:behavior.ranged_attack in their definition:
Related components
behavior.nearest_attackable_targetbehavior.melee_box_attackbehavior.stomp_turtle_eggbehavior.leap_at_targetbehavior.nearest_prioritized_attackable_targetbehavior.aquatic_charge_attackbehavior.charge_held_itembehavior.guardian_attackbehavior.ocelotattackbehavior.slime_attackbehavior.charge_attackbehavior.delayed_attackbehavior.dragonchargeplayerbehavior.dragonflamingbehavior.dragonstrafeplayerbehavior.fire_at_targetbehavior.knockback_roarbehavior.melee_attackbehavior.ram_attackbehavior.roarbehavior.send_eventbehavior.sonic_boombehavior.stomp_attackbehavior.summon_entity