Overview
Unlike vanilla Minecraft knockback which has random elements, this system provides:- Deterministic behavior - Same inputs = same outputs
- Directional knockback - Push toward a specific location
- Radial knockback - Push away from an origin point
- Vertical control - Separate horizontal and vertical knockback
- Vector-based calculation - Precise physics using vector math
Basic Usage
Directional knockback:Core Parameters
Horizontal knockback velocity/strength.Aliases:
velocity, vVertical knockback velocity/strength. Positive launches up, negative pushes down.Aliases:
velocityy, vyOrigin point for calculating knockback direction. For radial knockback, targets are pushed away from this location.
Whether to include vertical component in knockback direction.
true- 3D knockback (can launch diagonally)false- 2D knockback (only horizontal)
Knockback Direction Variable
Setknockback_direction to control directional knockback:
knockback_core.yml:58
How It Works
The knockback system uses vector mathematics:knockback_core.yml:56
Vector Addition
The destination is calculated as:direction_vector= normalized direction from origin to knockback_directionknockback_multiplier= kb value (with optional vertical component)
Initialization
knockback_core.yml:33
Example: Directional Knockback
Push enemies forward in the direction you’re facing:knockback_core.yml:10
Example: Cone Knockback
Knock enemies in a cone away from you:knockback_core.yml:15
Example: Vertical Launch
Launch enemies upward:knockback_core.yml:20
Example: Explosion Knockback
Radial knockback from an explosion center:Example: Pull Toward Location
Negative knockback to pull enemies:Example: Downward Slam
Knockback with negative vertical velocity:Integration with Damage
Use knockback in damage callbacks:Melee Integration
See Melee Core for examples of knockback in melee combat.Advanced: Custom Knockback Behavior
Access the destination vector for custom effects:Multi-Target Knockback
The foreach loop handles multiple targets:knockback_core.yml:29
Propel Mechanic
The final knockback uses MythicMobs’ propel mechanic:knockback_core.yml:76
Related Systems
- Damage Core - Combine knockback with damage
- Melee Core - Vanilla melee knockback implementation
- Spell Casting Handler - Add knockback to spells