feat(event): add FoodLevelChangeEvent - #524
Open
coolestandie wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_levelis writable and clamps values below zero to zero.itemis an optional copy of the consumedItemStack; exhaustion and other itemless changes reportNone.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.