#Right click detection

1 messages · Page 1 of 1 (latest)

upbeat current
#

What is the current best right click detection method, in the past I know carrot on a stick was the only and best option realistically,

I know there’s food, and interaction entities as alternatives. I want to make a datapack with a lot of different items that have abilities on them, so I just wanted to know what the best option is as of right now.

Please @ me with a reply so I can see it thank you 🤍

errant baneBOT
edgy yoke
#

@upbeat current

#

The consumable component is generally gonna be the best for most usecases

upbeat current
torpid nimbus
#

@upbeat current There have been a lot of additions to the consumable component that make it even better, such as the ability to enable sprinting and change or get rid of the speed penalty when using the item :)

#

Another good option is goat horns and the instrument component, since you can cause it to go on cooldown upon being used and, with a bit of clever coding, make it run something only once at the beginning

upbeat current
#

Is the instrument component applicable to any item like the consumable component or is it locked to goat horns also..

torpid nimbus
#

You can use execute if items to check if the player has an item in their weapon.mainhand slot

#

If you don't want to check for a specific item type but you want to check components, you can use *[<components>]

#

Also if you're checking for a specific custom data tag, here's a useful tip! If you use a ~ instead of a =, it will make the command check for the presence of that tag rather than demanding an exact match of the data you put in. I would always recommend you use it... for example: custom_data~{tag1:{tag2:1b}} will check if the item has a field called tag1 containing tag2 which is set to true, and won't care about any of the other data in it

torpid nimbus
upbeat current
upbeat current
#

I did

execute if items entity @s weapon.mainhand *[minecraft:custom_data={spell:1b}] run say yap

However it didn’t work, should change the :1b to be a =true or am I making an error

#

Oh I fixed it by including the click_check1b first

torpid nimbus
#

That way, it doesn't matter if there's other data such as click_check:1b as well ^w^

upbeat current
#

I really appreciate you helping me