Oligo
- Oligo
- JIRAUSER719129
- Europe/Stockholm
- Yes
- No
Changed Description:
Description:
When calling a function tag without macro arguments, not only will the first macro function fail but all succeeding functions in the tag are never executed.
Steps to reproduce:
1. Download the attached datapack which provides two functions named dev:a:
$say $(a)and dev:b:
say bwith a single function tag #dev:tag which runs dev:a before dev:b
{"values":["dev:a","dev:b"]}
2. Call /function #dev:tag
Expected behavior:
dev:a fails to instantiate due to missing macro arguments
dev:b executes as the next sequential function in the tag and prints the message "b" to the chat
Observed behavior:
dev:a fails to instantiate due to missing macro arguments
dev:b (and any number of succeeding functions) is never executed and no message is sent to chat
Changed Summary:
Uninstantiated macrofunctions terminate function tag completionFunctions containing uninstantiated macro commands terminate function tag completion
I've been testing this in 1.18.2 and I was not able to replicate this behavior. The vine disappears and there is no ghost item.
HOWEVER, I have still noticed some interesting behavior when using rewarded functions and moving items within the inventory.
My testing setup:
1. Place a shulker box in a the world at 0 -61 0 and replace the player's first inventory slot with an item (in my example it's a diamond).
2. Create an inventory_changed advancement which rewards a function which copies the player's hotbar into a shulker box:
3. Now move the diamond in the first hotbar slot to the second hotbar slot (open inventory GUI, hover over second slot, and press 1 button).
This should cause the diamond to move to the second slot and the "inventory changed" message displays in chat.
However, when you open the shulker box there will be two diamonds in the inventory spots corresponding to where the item started and where it ended. This turns out to be an intermediate inventory state that is normally not visible to the player.
If we repeat the same steps previously but this time add a command to our function file which removes the inventory_change advancement:
you will notice the "inventory changed" message prints twice and the shulker inventory should accurately reflect the player's inventory.
This demonstrates that minecraft handles inventory changes in two steps:
1. The game copies the item from the initial slot to the destination slot while holding any item in the destination slot in some storage space. This change is reflected in the first inventory_changed advancement granted.
2. The game then takes the item in storage space and places it into the initial slot. This change is reflected in the second inventory_changed advancement granted.
The inventory_changed advancement returns the function so fast it is able to resolve both of these steps in-game. I am unsure whether this behavior is intended by the devs or not, hence why I am leaving this as a comment.
If you wish to avoid this behavior, one can simply remove the function reward from the advancement and run a command as every player with the advancement in a tick function:
execute as @a[advancements={[advancement]=true}] run [function]