Mojira Archive
MC-265773

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

  1. /function mc-265773:test_4

    → Both 1 and 2 are printed

  2. /function mc-265773:test_3

    → Only 1 is printed

  3. /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.

data/mc-265773/advancements/a.json
{
  "criteria": {
    "": {
      "trigger": "impossible"
    }
  },
  "rewards": {
    "function": "mc-265773:a"
  }
}
data/mc-265773/functions/a.mcfunction
advancement revoke @s only mc-265773:a
say 1
say 2
data/mc-265773/functions/test_3.mcfunction
gamerule maxCommandChainLength 3
advancement grant @s only mc-265773:a
data/mc-265773/functions/test_4.mcfunction
gamerule maxCommandChainLength 4
advancement grant @s only mc-265773:a

Fixed

intsuc

[Mojang] Bartosz Bok

2023-10-11, 11:00 PM

2023-10-17, 02:18 PM

2023-10-17, 02:18 PM

3

4

Confirmed

Very Important

Platform

Commands

23w41a

23w42a