Fix get_tool_wear_after_use for one use (insta-break) #12945
Merged
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.
minetest/doc/lua_api.txt
Lines 3683 to 3688 in 6191baf
Currently
minetest.get_tool_wear_after_use(1, 0)
(tool should break after 1 use and doesn't have any wear yet) returns0
. Actually it should return65536
in order to instantly break the tool. The wrong return value is caused byModApiUtil::l_get_tool_wear_after_use
incorrectly casting the return value ofcalculateResultWear
fromu32
tou16
. This PR fixes that.Does it resolve any reported issue?
No, I thought it was small enough not to open an issue.
If not a bug fix, why is this PR needed? What usecases does it solve?
It's a bug fix.
To do
This PR is Ready for Review.
How to test
Try
minetest.get_tool_wear_after_use(1, 0)
. It should return65536
.