minecraft:apply_knockback_rules

Defines how an entity applies knockback.

Properties

PropertyTypeDefaultWhat it does
presetsList of object[]Array of rules instances defining how knockback should be applied to the entity.
filterObject 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.
testText—The name of the test to apply.
subjectBoolean or Integer or Decimal or Text—The subject of this filter test.
operatorBoolean or Integer or Decimal or Text—The comparison to apply with 'value'.
domainBoolean or Integer or Decimal or Text—The domain the test should be performed in.
valueBoolean or Integer or Decimal or Text—The value being compared with the test.
horizontal_powerDecimal1Power with which a target should be knocked backwards.
vertical_powerDecimal0.4Power with which a target should be knocked upwards.
vertical_velocity_capDecimal0.4Maximum allowed Y velocity after target's knockback rules have been evaluated.
check_if_target_is_immersed_in_waterBooleanfalseWhether or not the target should be fully immersed in water for the knockback rules to apply.
slowdown_scaleDecimal0 to 10.5Scaling factor to apply to the target's velocity before applying knockback.
scale_with_damageBooleanfalseScaling factor to the magnitude of knockback based on the inverse square of the damage.
knockback_modeTextrelative_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_approachTextreapply_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