Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-265773

Functions executed as advancement rewards are executed at the top level

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 23w42a
    • 23w41a
    • None
    • Confirmed
    • Commands
    • Very Important
    • Platform

      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
      

            boq [Mojang] Bartosz Bok
            intsuc intsuc
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: