Minecraft Commands – Click-Emerald Reaction in Minecraft Java Edition

minecraft-commandsminecraft-java-edition

For fun, I'm making an arcade template thingy, and I want a shop where you can buy perks or costumes etc. by clicking on an emerald, like Hypixel. Ive tried "/scoreboard players test @p Shop 0 1" after clicking on the emerald which should increase the Shop score because I set the Criteria Type to "/scoreboard objectives add Test stat.useItem.minecraft.emerald" This is problably the wrong criteria, or "Using" an emerald is different then clicking on it 😛 Is this just an item without a use?

Best Answer

From the Minecraft Wiki (talking about stat.useItem):

The value increments when a player uses a block or item. "Use" is defined as when:

A shovel, a pickaxe, an axe, flint and steel, shears, a hoe, bows, or a sword could consume durability; the value increments even if no durability is consumed, such as when any item that requires left click to use destroys a torch. For fishing rods and carrot on a sticks, the value increments whenever they are right-clicked; durability does not have to be consumed at all. The value does not increment when armor consumes durability.

A block is placed.

A painting, spawn egg, any type of minecart, item frame, boat,eye of ender, ender pearl, egg, snowball, bow, any type of throwable potion, Bottle o' Enchanting, or fishing rod spawns an entity.

One of the two usable dyes are properly used. Either when cocoa beans place cocoa pods on jungle wood or bone meal is used to grow plants, such as crops or grass. The value does not increment when a dye is used on a sheep.

A bucket of milk, potion, or any food, save cake which is placeable, is consumed.

An empty map, bucket, lava bucket, water bucket, milk, book and quill, or potion creates a new item. The value does not increment when bowl becomes mushroom stew or a bucket becomes milk.

A record is placed in a jukebox. Each record has a different stat.

The value, however, does not increment when items are used on mobs, whether to name, tame, feed, breed, saddle, leash, shear, milk, or gather stew from; when armor is put on directly; when leather armor is washed in a cauldron; and all instances mentioned above.

From reading this, it appears that emeralds cannot be 'used'. However, from the same page, I read about a stat.drop criteria, incremented when you press 'q' with an item in your hand. It appears as though this might work for what you're trying to do.