mojira.dev
MC-169271

Incorrect age tag from item dispensed or dropped from a dropper from a datapack context

 

How to recreate the bug:

The datapack provided has the following code:

execute as @e[type=item,nbt={Age:0s}] run say Age 0
execute as @e[type=item,nbt={Age:1s}] run say Age 1
execute as @e[type=item,nbt={Age:2s}] run say Age 2
execute as @e[type=item,nbt={Age:3s}] run say Age 3
execute as @e[type=item,nbt={Age:4s}] run say Age 4

Put it on a world's datapack folder and run the /reload command.

If you drop an item from your inventory in the chat will apear all numbers [0,1,2,3,4].

But if dropped by a dispenser or dropper, the chat will only show [1,2,3,4].

Thus we can conclude that the datapack code could not have selected the item in its first tick.

!!! This is an datapack context exclusive bug, if you place down a repeating command block, set to always active with the command "execute as @e[type=item,nbt={Age:0s}] run say Item Detected" it will succesfully show in the chat the message "[<item>] Item Detected" when an item is dropped by a dispenser/dropper.

 

Possible cause:

To ease the fixing of the issue, my guess is that the item from the dispenser is ticked before the datapack functions, probably in the block update of the dispenser being activated, so it can move in the direction of its randomly assinged motion tag. An easy fix would be to set age to 0 after the item ticks.

 

Linked issues

Attachments

Comments 3

I wouldn't say this is a bug, just an unfortunate inevitability of the order of things.
Datapack #tick must run independently of dimensions, so it runs before everything. Dispensers and entity ticks must run in their own dimension. So tile ticks are processed, creating the item, then items are ticked, increasing its age. The #tick was too early.
Command blocks are also inside a dimension, so their tile can tick before items are ticked.

Just ran into this exact issue when attempting to optimize a datapack. Correct me if I'm wrong, but this means that any items created by a tile entity can't be handled by functions during the first tick of their existence regardless of what you do, right? Meaning that any work-around that could be done using functions would essentially involve waiting for the next game tick?

Thank you for your report!
We're actually already tracking this issue in MC-117360, so I resolved and linked this ticket as a duplicate.

However, that ticket has already been resolved. That means that this is not considered a bug and won't be fixed. Please do not leave a comment on the linked ticket.

If you haven't already, you might like to make use of the search feature in the future to see if the issue has already been reported.

Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki

Germano Barbosa Da Silva Júnior

(Unassigned)

Unconfirmed

(Unassigned)

1.15.1

Retrieved