The bug
When you right click with a carrot on a stick it always increases the usage statistic value for it even if you did not really use it.
I know that this is a technique used by map makers, but it would be better to have a generic way to detect right clicks than to rely on situations like this.
How to reproduce
Add an objective with the
minecraft.used:minecraft.carrot_on_a_stick
criteria, set it to display on your sidebar, and set your score to 0 so it displays/scoreboard objectives add carrotOnAStick minecraft.used:minecraft.carrot_on_a_stick /scoreboard objectives setdisplay sidebar carrotOnAStick /scoreboard players set @s carrotOnAStick 0
Right click with a carrot on a stick while not riding a pig
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The method net.minecraft.item.ItemCarrotOnAStick.onItemRightClick(World, EntityPlayer, EnumHand)
always increases the usage statistic value.
Linked issues
Attachments
Comments 16
No, it tracks how often you perform the item's use. stat.useItem.minecraft.stick
is never incremented. Items with different uses increment at different times. For example – throwing a snowball, eating a porkchop, attacking with a sword, planting seeds. Simply right-clicking with the seeds won't increment the stat unless they were planted.
I'd like to point out that this issue creates a gateway for custom active items to be implemented in maps. Carrot on a stick can be used as a "unversral right click detector", and paired with a resource pack durability predecate for textures, to generate up to 26 custom items - or even more if negative durability values are used.
The rare case of having to detect a pig speed boosted with a carrot on a stick over unmodded custom items, this is a tough choice indeed
The statistic stat.useItem tracks how many times you use the "use" key while holding an item. For example, if you do /scoreboard objectives add Stick stat.useItem.minecraft.stick it will tell you how many times you right clicked with a stick in your hand.