Functions executed as advancement rewards are executed at the top level
The bug
maxCommandChainLength and maxCommandForkCount are only obtained and copied when commands are executed at the top level, which creates a new execution context. Changes in these gamerules usually do not affect execution under that execution context.
However, because functions executed as advancement rewards are also executed at the top level, you can execute a function under another execution context with possibly modified maxCommandChainLength and maxCommandForkCount. Considering MC-143266, this behavior may be unintentional.
How to reproduce
/function mc-265773:test_4
→ Both 1 and 2 are printed
/function mc-265773:test_3
→ Only 1 is printed
/function mc-265773:test_4
→ Both 1 and 2 are printed
These results imply that maxCommandChainLength modified in a function affects the execution of a function executed as a advancement reward.
{
"criteria": {
"": {
"trigger": "impossible"
}
},
"rewards": {
"function": "mc-265773:a"
}
}
advancement revoke @s only mc-265773:a say 1 say 2
gamerule maxCommandChainLength 3 advancement grant @s only mc-265773:a
gamerule maxCommandChainLength 4 advancement grant @s only mc-265773:a
2023-10-11, 11:00 PM
2023-10-17, 02:18 PM
2023-10-17, 02:18 PM
3
4