#right click detection
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
🙇 If nobody has answered you by <t:1732733798:t>, feel free to use the Summon Helpers button to ping our helper team.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
Don't forget to close or resolve your old questions once you're done with them. It makes our lives much easier! :D
Open question: #1310302374409277521
"criteria": {
"using_item": {
"trigger": "minecraft:using_item",
"conditions": {
"item": {
"items": "golden_hoe",
"components": {
"minecraft:custom_data": {
"tag:smg": {}
}
}
}
}
}
},
"rewards": {
"function": "jg:throw"
}
}```
its supposed to be detecting if a player is using a golden hoe with the tag of smg
Pretty sure your custom data is wrong. Show us the components of the actual item?
Yeah your custom data in the advancement is not the same as it is here
In the advancement, you need custom_data:{"smg":1}
ok ill change that
this
"criteria": {
"using_item": {
"trigger": "minecraft:using_item",
"conditions": {
"item": {
"items": "golden_hoe",
"components": {
"custom_data:{"smg":1}": {
}
}
}
}
}
},
"rewards": {
"function": "jg:throw"
}
}```
now wont let me grant my self the advancement
Did you revoke the advancement in the function?
it does in the throw function
and i tried to revoke it in game but it just didint show up
"custom_data:{"smg":1}" should be "custom_data":{"smg":1}
@rustic perch
Does it work now? ^^
i can grant the command but the golden hoe doesent
is it possible to do it with interaction entitys
You shouldn't need to, if you're still having trouble with the advancement then that's what we should focus on fixing
ok
but yeah im still having issues with it
Such as?
just wont trigger
ill right click with a golden hoe and not at the ground and it wont trigger the function
Does the golden hoe have a food or consumable component?
...did you give it a food or consumable component in the give command?
no
So that's why
how do i do it
Rightclick Detection Food
>>> This is an example, so you'll need to change a few things for your actual datapack:
- Change
stickto the item you want to detect - Change
namespaceto your namespace - Change
custom_stickto whatever custom data you want
Note: You can use any item for this, but if it has existing right-click functionality (like placing a block), it will keep that.
This is the command to give you a stick with the custom food component (You can run this in the chat to test it, or put it in a function to trigger when you want):
give @s stick[minecraft:food={nutrition:0, saturation:0, can_always_eat:true, eat_seconds:999999999}, minecraft:custom_data={custom_stick:true}]
click_food.json (located in your pack's advancement folder)
{
"criteria": {
"requirement": {
"trigger": "minecraft:using_item",
"conditions": {
"item": {
"items": [
"minecraft:stick"
],
"predicates": {
"minecraft:custom_data": {"custom_stick": true}
}
}
}
}
},
"rewards": {
"function": "namespace:rightclick_run"
}
}
rightclick_run.mcfunction (located in your pack's function folder)
# revokes the advancement from the player so it can be used again
advancement revoke @s only namespace:click_food
# announces the use of the item in chat, feel free to replace this with whatever
say I successfully used food component detection!
How it works
We've added a food component to our custom stick item, allowing it to be consumed like food. The player won't actually eat it, since eat_seconds is set to 999999999, so it would take them over 30 years. The food component lets the player try to eat it, which can be detected using an advancement. That advancement runs a function which removes the advancement so it can be triggered again next tick, and runs whatever code you want to the item to trigger.
If you're in 1.21.2+, you need to use consumable instead of food, but the same principle applies other than that
I don't understand
instead of using a predicate
Where are you using a predicate?
"criteria": {
"requirement": {
"trigger": "minecraft:using_item",
"conditions": {
"item": {
"items": [
"minecraft:stick"
],
"predicates": {
"minecraft:custom_data": {"custom_stick": true}
}
}
}
}
},
"rewards": {
"function": "namespace:rightclick_run"
}
}```
ok
That's not remotely the problem
The problem is that Golden Hoes do not do anything detectable when you right click with them, unless you're looking at a block than can be tilled into farmland
So there's nothing for the advancement to be triggered by. You give it the food component so that it can be eaten, and therefore right clicked, allowing the advancement to detect it
just checked my version is 1.21 not 1.21.2
Ok, then you can follow the tutorial as written
ok
still not working
nvm
now it is
Your question, #1311397789661528075 (right click detection), was resolved!
#1311397789661528075 message
1d5h47m
Re-opened the channel. Make sure to close it again once you're done.