1. Wiki
  2. /Entities
  3. /minecraft:behavior.ranged_attack

minecraft:behavior.ranged_attack

Don't want to write this by hand? GodCraft sets minecraft:behavior.ranged_attack for you with a switch.Get GodCraft

Overview

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

FieldTypeDefaultDescription
burst_shotsinteger1How many shots are fired in one charged burst.
target_in_sight_timenumber1Seconds the mob must see the target before it moves toward it.
burst_intervalnumber0Seconds between each shot in a burst.
charge_charged_triggernumber0Extra seconds, added to charge_shoot_trigger, before the charge is complete. The charge drops while the target is out of sight.
charge_shoot_triggernumber0How long the mob charges before firing a burst (this value is doubled in game). Set it above 0 to turn on charged bursts.
attack_intervalFloatRange{"max":-1,"min":-1}Random reload time, in seconds, between normal shots. It grows with distance to the target.
attack_rangeFloatRange{"max":0,"min":0}The mob only shoots when the target is between these distances.
x_max_rotationnumber30How far, in degrees, the mob can tilt up or down while aiming.Range: 0 to …
y_max_head_rotationnumber30How far, in degrees, the mob can turn its head sideways while aiming.Range: 0 to …
ranged_fovnumber90Field of view, in degrees, used to spot a target to shoot.Range: 0 to …
speed_multipliernumber1Speed multiplier while moving toward the target during the attack.
set_persistentbooleanfalseIf true, the mob will not despawn after it targets a player.
swingbooleanfalseIf true and the mob has a swing animation, it swings its arm each time it shoots.
in_range_movement_modeRangedAttackGoalDefinition::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.
priorityinteger0Decides which goal wins when several want to run: lower numbers run first.Range: 0 to …
control_flagsGoal's control flags[]noneLists 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
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more