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

"/execute if function" always fails and "/execute unless function" always succeeds if run from a function

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 23w41a
    • 23w31a
    • None
    • Confirmed
    • Data Packs
    • Important
    • Platform

      /execute if|unless function <function> works normally in chat.

      However, if run through a datapack /execute if <function> always fails regardless of the <function>'s return value and /execute unless <function> always succeeds.

      MINECRAFT SNAPSHOT 23W31A

      • A succeessful call is defined as a function that:
        • Uses the return command to return a value
        • The return value is not 0

      Steps to reproduce:

      Create two functions, one that always returns 0 and another that always returns something other than 0.

      Run these four commands in chat to get correct behaviour:
       

      /execute if function a:return_0 
      >Test failed
      /execute if function a:return_5
      >Test passed
      /execute unless function a:return_0
      >Test passed
      /execute unless function a:return_5
      >Test failed

       

      ✅ The second and third commands are successful.

      Create a function to run these commands:

      execute if function a:return_0 run say success 1
      
      execute if function a:return_5 run say success 2
      
      execute unless function a:return_0 run say success 3
      
      execute unless function a:return_5 run say success 4

       

      /function a:test
      >Executed 12 commands from function 'a:test'
      >success 3
      >success 4

      ❌ The third and fourth commands are successful.

      Datapack: bug-2.zip

        1. Screenshot4.png
          Screenshot4.png
          17 kB
        2. Screenshot3.png
          Screenshot3.png
          19 kB
        3. Screenshot2.png
          Screenshot2.png
          87 kB
        4. Screenshot1.png
          Screenshot1.png
          284 kB
        5. bug-2.zip
          1 kB

            boq [Mojang] Bartosz Bok
            AlexWithADuck AlexWithADuck
            Votes:
            24 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: