Skip to content

feat(knockback): expose native calculation parameters - #508

Open
coolestandie wants to merge 2 commits into
EndstoneMC:developfrom
coolestandie:feat/knockback-engine
Open

feat(knockback): expose native calculation parameters#508
coolestandie wants to merge 2 commits into
EndstoneMC:developfrom
coolestandie:feat/knockback-engine

Conversation

@coolestandie

Copy link
Copy Markdown

Adds a cancellable ActorKnockbackPrepareEvent before BDS calculates knockback, while keeping ActorKnockbackEvent as the final-vector event.

What this adds

  • KnockbackParameters in the C++ and Python APIs, exposing the native horizontal and vertical power, vertical velocity cap, slowdown scale, damage scaling, attacker slowdown, legacy-rule check, extra power and extra-knockback approach.
  • ActorKnockbackPrepareEvent, where plugins can change the damage, horizontal direction and native parameters before BDS evaluates them, or cancel the calculation entirely.
  • Mob.no_damage_ticks / Mob::getNoDamageTicks() and setNoDamageTicks() for hit-delay control.
  • Python bindings, generated stubs, API exports, unit tests, integration snapshots and CHANGELOG entries.

Where it fires

The event fires directly in Mob::knockback before the original BDS implementation is called. The modified values are copied back into the native KnockbackParameters structure and then passed to BDS, so the engine still performs the actual knockback calculation.

BDS can invoke Mob::knockback again while applying extra knockback. The prepare event therefore fires for each native calculation, matching the engine path rather than hiding the second calculation.

Cancellation and final-vector event

Cancelling ActorKnockbackPrepareEvent returns before BDS calculates or applies knockback. ActorKnockbackEvent remains unchanged and still runs after the native calculation, allowing plugins to inspect, replace or cancel the resulting velocity delta.

Vanilla behavior

The hook checks whether either knockback event has listeners. With no listeners, it calls the original function immediately with the untouched native arguments. With listeners, every value starts from the parameters supplied by BDS; this change introduces no global configuration or hard-coded knockback defaults.

Testing

  • Full GitHub Actions workflow passed on the fork on Ubuntu and Windows before rebasing onto the latest develop.
  • Unit coverage added for KnockbackParameters, with Python event integration snapshots and generated-stub validation.
  • Tested on a Windows Bedrock Dedicated Server with ground and air knockback adjustments, extra knockback, cancellation and no-damage-tick changes.

@coolestandie
coolestandie marked this pull request as ready for review August 21, 2026 16:58
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (a872cd2) to head (a3aa0ed).
⚠️ Report is 73 commits behind head on develop.

Additional details and impacted files
@@      Coverage Diff       @@
##   develop   #508   +/-   ##
==============================
==============================

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant