minecraft:apply_knockback_rules
Defines how an entity applies knockback.
Properties
| Property | Type | Default | What it does |
|---|---|---|---|
presets | List of object | [] | Array of rules instances defining how knockback should be applied to the entity. |
filter | Object or List of object | {"AND": null, "NOT": null, "OR": null, "all": null, "all_… | Filter for the entity type that will be affected by these knockback rules. |
test | Text | — | The name of the test to apply. |
subject | Boolean or Integer or Decimal or Text | — | The subject of this filter test. |
operator | Boolean or Integer or Decimal or Text | — | The comparison to apply with 'value'. |
domain | Boolean or Integer or Decimal or Text | — | The domain the test should be performed in. |
value | Boolean or Integer or Decimal or Text | — | The value being compared with the test. |
horizontal_power | Decimal | 1 | Power with which a target should be knocked backwards. |
vertical_power | Decimal | 0.4 | Power with which a target should be knocked upwards. |
vertical_velocity_cap | Decimal | 0.4 | Maximum allowed Y velocity after target's knockback rules have been evaluated. |
check_if_target_is_immersed_in_water | Boolean | false | Whether or not the target should be fully immersed in water for the knockback rules to apply. |
slowdown_scale | Decimal0 to 1 | 0.5 | Scaling factor to apply to the target's velocity before applying knockback. |
scale_with_damage | Boolean | false | Scaling factor to the magnitude of knockback based on the inverse square of the damage. |
knockback_mode | Textrelative_horizontal, hit_direction | "relative_horizontal" | Defines how knockback is applied to the target: - "relative_horizontal": Applies knockback along the horizontal direction from the attacker to the target. - "hit_direction": Applies knockback based on the hit direction and the point of impact (e.g. hits to the bottom of the entity or from below push it upward, hits on the left side of the entity push it to the right). |
extra_knockback_approach | Textreapply_default, multiply_reduced | "reapply_default" | Defines the approach for combining extra knockback from enchantments or sprinting: - "reapply_default": Reapplies knockback again with default knockback parameters, i.e. values not defined by this component. - "multiply_reduced": Multiplies the extra knockback with the base knockback and a reduction factor, and adds it to the base knockback. |
Example from the game files
This is how vanilla Drowned uses it in Minecraft Bedrock 1.26.60.5:
{
"minecraft:apply_knockback_rules": {
"presets": [
{
"horizontal_power": 0.6,
"vertical_power": -0.6,
"vertical_velocity_cap": -0.4,
"check_if_target_is_immersed_in_water": true
}
]
}
}Used by 4
Vanilla entities with minecraft:apply_knockback_rules in their definition:
Related components
physicscollision_boxtype_familyconditional_bandwidth_optimizationnameableis_hidden_when_invisiblepushable_by_blockpushable_by_entitylootcan_climbis_babyballoonableambient_sound_intervalvariantpushablepersistentis_tameddimension_boundis_saddledinput_ground_controlledis_shakingmark_variantrenders_when_invisiblecan_fly