I am in Java 1.14.4 and I'm trying to create a custom crafting system using donkeys. ATM I am adding the ability for the items in the crafting grid to subtract their count whenever an item has been crafted.
Here I use Slot 2b as an example. I get the item count of whatever item is in Slot 2b, store that count into a scoreboard value, subtract the count by 1, and then store the count back into the donkey's inventory. I do this with:
execute store result score @s craftItemCount run data get entity @s Items[{Slot:2b}].Count 1
scoreboard players remove @s craftItemCount 1
execute store result entity @s Items[{Slot:2b}].Count byte 1 run scoreboard players get @s craftItemCount
However, the item count isn't automatically updated if the player has the chest donkey's GUI open. The inventory screen has to be closed and then reupdated for this to take effect. Meaning if the player takes the items out of the crafting grid after crafting an item, then the item count won't be subtracted at all and items could be easily duplicated. Is there a way around this?
/data modify
insists that the data is already there, but/data get
doesn't show it. Sadly bugs that can only be reproduced by changing the NBT of an entity during its lifetime are not accepted on the bug tracker (because it's an unsupported feature), so I can't even create a report for it.execute store result entity @e[type=donkey,limit=1] Items[{Slot:2b}].Count byte 1 run scoreboard players get @e[type=donkey,limit=1] craftItemCount
. It will modify the data, but not when you are within the donkey's inventory.