Mojira Archive
MC-264710

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

/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

Fixed

AlexWithADuck

[Mojang] Bartosz Bok

2023-08-07, 11:23 PM

2023-10-11, 08:52 AM

2023-10-11, 08:52 AM

24

17

Confirmed

Important

Platform

Data Packs

23w31a

23w41a