Background information / Context
Commands have two types of return values: success and result. These can be copied to other places using “execute store success/result ...
“. Return values for functions in particular behave like this:
“
return <value>
” sets the success to 1 and the result to <value>“
return fail
” sets success and result to 0“
return run <command>
” takes the values from the command that comes after it.If no “
return
” command is present, success and result are not undefined (Using “execute store result ...
” will not set anything, not even a default value of 0)
Expected behaviour
Using “return run <command>
” always carries over the success and result return values from the command that comes after it, even if that command has no return values (as it’s established that commands are already allowed not to have a return value, as shown above).
Actual behaviour
If <command> has no return value (success, result or both are undefined), “return run <command>
“ will set any undefined return values to 0 by default. This means that it is impossible to differentiate between “return fail
“ and not having a return value in these situations, in addition to it being inconsistent with everything else.
How to reproduce
Download the attached Data Pack (Written for 1.21.8) and put it in your world’s “datapacks” folder
Boot up your server or world, or run “
/reload
” if it’s already runningRun the provided functions and observe the results
Functions:
(bug:test1) Example function with no “
return
” command(bug:test2) Example function with “
return 1
“(bug:test3) Example function with “
return fail
”(bug:return_run_test1/2/3) Example function that uses “return run” on the respective test function
(bug:print_values) Run “
/function bug:print_values {function_name:'<function name, like test1>'}
“ to print the respective function’s success and result values in chat.
Interpreting the results:
Running the print_values function for each test function (/function bug:print_values {function_name:'test1'}
) gives you the following return values:
(bug:test1) Success: -, Result: -
(bug:test2) Success: 1, Result: 1
(bug:test3) Success: 0, Result: 0
(bug:return_run_test1) Success: 0, Result: 0
(bug:return_run_test2) Success: 1, Result: 1
(bug:return_run_test3) Success: 0, Result: 0
This demonstrates that “test1“ and “return_run_test1” have different return values (even though they should be the same) and that “return_run_test1” and “return_run_test3” are indistinguishable.
Attachments
Comments 0
No comments.