minecraft:behavior.ranged_attack for you with a switch.Get GodCraftOverview
minecraft:behavior.ranged_attack is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Lets the mob attack from a distance by shooting projectiles, like a skeleton or blaze. The projectile itself is set with minecraft:shooter. Set charge_shoot_trigger above 0 for charged burst attacks.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
burst_shots | integer | 1 | How many shots are fired in one charged burst. |
target_in_sight_time | number | 1 | Seconds the mob must see the target before it moves toward it. |
burst_interval | number | 0 | Seconds between each shot in a burst. |
charge_charged_trigger | number | 0 | Extra seconds, added to charge_shoot_trigger, before the charge is complete. The charge drops while the target is out of sight. |
charge_shoot_trigger | number | 0 | How long the mob charges before firing a burst (this value is doubled in game). Set it above 0 to turn on charged bursts. |
attack_interval | FloatRange | {"max":-1,"min":-1} | Random reload time, in seconds, between normal shots. It grows with distance to the target. |
attack_range | FloatRange | {"max":0,"min":0} | The mob only shoots when the target is between these distances. |
x_max_rotation | number | 30 | How far, in degrees, the mob can tilt up or down while aiming.Range: 0 to … |
y_max_head_rotation | number | 30 | How far, in degrees, the mob can turn its head sideways while aiming.Range: 0 to … |
ranged_fov | number | 90 | Field of view, in degrees, used to spot a target to shoot.Range: 0 to … |
speed_multiplier | number | 1 | Speed multiplier while moving toward the target during the attack. |
set_persistent | boolean | false | If true, the mob will not despawn after it targets a player. |
swing | boolean | false | If true and the mob has a swing animation, it swings its arm each time it shoots. |
in_range_movement_mode | RangedAttackGoalDefinition::InRangeMovementMode | "hold_position" | How the mob moves while the target is in range: "hold_position" stands still and shoots, "follow_target" keeps walking closer up to the minimum range. |
priority | integer | 0 | Decides which goal wins when several want to run: lower numbers run first.Range: 0 to … |
control_flags | Goal's control flags[] | none | Lists the body parts this goal takes control of (such as move, look or jump), so goals that need the same part don't run together. |
Example
Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):
BP/entities/<name>.json
{
"minecraft:behavior.ranged_attack": {
"burst_shots": 1,
"target_in_sight_time": 1,
"burst_interval": 0,
"charge_charged_trigger": 0,
"charge_shoot_trigger": 0,
"attack_interval": {
"max": -1,
"min": -1
},
"attack_range": {
"max": 0,
"min": 0
},
"x_max_rotation": 30
}
}