Skip to content

feat(event): add FoodLevelChangeEvent - #524

Open
coolestandie wants to merge 2 commits into
EndstoneMC:developfrom
coolestandie:feat/food-level-change-event
Open

feat(event): add FoodLevelChangeEvent#524
coolestandie wants to merge 2 commits into
EndstoneMC:developfrom
coolestandie:feat/food-level-change-event

Conversation

@coolestandie

Copy link
Copy Markdown

Added events

  • FoodLevelChangeEvent — called when a player's food level changes, allowing plugins to cancel or modify the resultant food level and inspect the consumed item when available.

Implementation

Dispatched around Bedrock's player eating, exhaustion, cake and Saturation paths. The event is applied before the native hunger transaction, preserving item-backed context and allowing cancellation or mutation to affect the final food level.

Notes

  • food_level is writable and clamps values below zero to zero.
  • item is an optional copy of the consumed ItemStack; exhaustion and other itemless changes report None.
  • The event is exposed through the C++ API, Python bindings and generated stubs.

Testing

Verified with a fresh Windows build, C++ tests, Python unit tests and a live BDS 1.26.45.1 server. Live validation covers cancellation, mutation, item-backed changes, itemless exhaustion changes and removing Saturation during the callback.

C++ tests: 340 passed. Python unit tests: 248 passed, 13 skipped. Live targeted event checks: 5 passed.

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 12.06%. Comparing base (46eff9f) to head (73de4f8).

Files with missing lines Patch % Lines
...ude/endstone/event/actor/food_level_change_event.h 0.00% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #524      +/-   ##
===========================================
- Coverage    12.09%   12.06%   -0.04%     
===========================================
  Files          371      372       +1     
  Lines         9325     9335      +10     
  Branches      3338     3340       +2     
===========================================
- Hits          1128     1126       -2     
- Misses        7529     7539      +10     
- Partials       668      670       +2     

☔ 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