I am working on a small datapack that adds magic rituals to the game, I added custom blocks but I need to add interactions.
The best way to do it is with advancements, I tried it but I am using a hopper for that custom block because of its shape. I need some help with the advancements (I dont know much about these). I want to make so that when a player right clicks on a hopper (locked and has a custom name) while holding any item, then a function is executed.
#Block interaction using Advancements
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
Someone will come and help soon!
💬 While you wait, take this time to provide more context and details.
🙇 If nobody has answered you by <t:1744714132: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
you can use https://misode.github.io/advancement/ to generate an advancement that has a requirement with the trigger item_used_on_block then you can add conditions like which block or if there is a marker nearby. Then you can reward a function, in that function make sure to also revoke the advancement
I do not know how advancements work, even with the datapack generator
well an advancement is something you can receive by doing a certain thing, that thing is called a requirement. Each requirement can be met when the trigger happens (for example: item_used_on_block -> when an item (or an empty hand) is used on a block) and all conditions are also met. When an advancement is granted, it can also give you some rewards, these can be functions, loot_tables, xp etc..
"criteria": {
"requirement": {
"trigger": "minecraft:item_used_on_block",
"conditions": {
"player": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:reference",
"name": "server:entity/sneaking_with_item"
}
}
],
"location": [
{
"condition": "minecraft:location_check",
"predicate": {
"block": {
"blocks": [
"minecraft:hopper"
]
}
}
}
]
}
}
},
"rewards": {
"function": "server:block/podium/click"
},
"requirements": [
[
"requirement"
]
]
}```
The best way to learn what advancements are is to try to use them yourself and experement even if you don't know what you're doing
I got this from a datapack
I don't really understand how I should help you
You can't expect yourself to fully understand advancements by looking at one for 2 seconds and then asking some explanation
just experement with them
okay
try stuff and if it doesn't work well change smth
Pretty sure it won't work correct me if I'm wrong
I think there is another trigger for it
It does work. Only for some block interactions (press button, open door, flick lever, plus some more) there is an extra advancement called default_block_use
yeah that one
What does the default block use do?
.
The advancement works but only when I place a block while looking at the hopper (in the code). I want to make so that it detects any item in my hand and executes when any item is right clicked on hopper
ooh well yea try using default_block_use
Closed for inactivity
This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.
Any further messages or reactions will re-open this thread.
Closed for inactivity
This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.
Any further messages or reactions will re-open this thread.