How do you increase an objective from a certain amount of items in a player's inventory?
The solution is to use command stats and clear
with a count of 0. This will clear 0 items, but it will set a command stat with the total number of matching items in the inventory, cleared or not.
The commands are as follows:
# Tell all players to store the AffectedItems stat of any commands
# they run in their own TempKEnt objective.
stats entity @a set AffectedItems @s TempKEnt
# Make sure all players have a score in TempKEnt, since /stats can
# only update scoreboard values, not create them.
scoreboard players add @a TempKEnt 0
# Have all players run the clear command to get the item count.
execute @a ~ ~ ~ clear @s minecraft:prismarine_shard -1 0
# Tell all players to stop storing their AffectedItems stat.
stats entity @a clear AffectedItems
In 1.13, this will be much simpler:
# Does not work in 1.12!
execute as @a store result score @s TempKEnt run clear @s minecraft:prismarine_shard 0