minecraft:behavior.melee_attack for you with a switch.Get GodCraftOverview
minecraft:behavior.melee_attack 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 chase its target and hit it up close. Damage comes from the minecraft:attack component.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
reach_multiplier | number | 2 | Multiplied by the mob's size to get how close it must be to hit.Range: 0 to … |
on_kill | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | Event that fires when this mob kills its target. |
cooldown_time | number | 1 | Seconds to wait between two attacks.Range: 0 to … |
melee_fov | number | 90 | Field of view in degrees used to spot a target to hit.Range: 0 to … |
x_max_rotation | number | 30 | Most degrees the mob can tilt up or down while looking at the target.Range: 0 to … |
y_max_head_rotation | number | 30 | Most degrees the mob can turn its head sideways while looking at the target.Range: 0 to … |
random_stop_interval | integer | 0 | Gives a 1 in N chance to stop attacking, where N is this number.Range: 0 to … |
attack_once | boolean | false | If true, the mob only ever does this attack one time. |
can_spread_on_fire | boolean | false | If true, a burning mob with empty hands sets its target on fire when it hits. |
min_path_time | number | 0.2 | Shortest wait in seconds before the path to the target is worked out again.Range: 0 to … |
max_path_time | number | 0.55 | Longest wait in seconds before the path to the target is worked out again.Range: 0 to … |
path_fail_time_increase | number | 0.75 | Seconds added to the path wait when the mob gets stuck.Range: 0 to … |
inner_boundary_time_increase | number | 0.25 | Seconds added to the path wait when the target is past path_inner_boundary.Range: 0 to … |
outer_boundary_time_increase | number | 0.5 | Seconds added to the path wait when the target is past path_outer_boundary.Range: 0 to … |
path_inner_boundary | number | 16 | Distance after which inner_boundary_time_increase is applied.Range: 0 to … |
path_outer_boundary | number | 32 | Distance after which outer_boundary_time_increase is applied.Range: 0 to … |
speed_multiplier | number | 1 | Speed multiplier while moving toward the target.Range: 0 to … |
require_complete_path | boolean | false | If true, the mob only chases when a full path to the target exists. |
track_target | boolean | false | If true, the mob keeps following its target even without a sensing component. |
attack_types | string | "" | Which entity types this mob will attack. |
on_attack | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | Event that fires each time an attack lands. |
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.melee_attack": {
"reach_multiplier": 2,
"on_kill": {
"event": "",
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
},
"target": "self"
},
"cooldown_time": 1,
"melee_fov": 90,
"x_max_rotation": 30,
"y_max_head_rotation": 30,
"random_stop_interval": 0,
"attack_once": false
}
}