2
Inventory check (Help me pls)perm_data_setting
How can I check, that player has 4+ items (flint or custom item for example) in the inventory?
When I use
When I use
execute if data entity @s {Inventory:[{id:minecraft:flint,Count:4b}]} run <...>it works only when player has exactly 4 items in one of slots (other slots can contain not 4, so, if you have 64 and 4, it would work)1
If you want to check if something is greater or less than a value, you usually store the value in a score from /data get, then run an /execute if score command. If you want to check data values, you use /data get instead of /execute if data.
However, in this scenario when specifically checking items in the inventory, you can use a cool quirk of the /clear command, where if you clear 0 items of something, it returns the number of items you have. It would look like this:
You can add nbt to this as well for custom items, e.g. clear @s minecraft:flint{customtag:1b} 0
Hope that helps!
However, in this scenario when specifically checking items in the inventory, you can use a cool quirk of the /clear command, where if you clear 0 items of something, it returns the number of items you have. It would look like this:
execute store result score <name> <scoreboard> run clear @s minecraft:flint 0
execute if score test itemstats matches 4.. run say yesYou can add nbt to this as well for custom items, e.g. clear @s minecraft:flint{customtag:1b} 0
Hope that helps!
