The using_item advancement keeps trigger even when the player isn't holding down right mouse button if the reward function has a command that let the player teleport through dimension, causing the player to be stuck at a position unless they no longer holding the item.
The advancement:
{
"criteria":
{
"book":
{
"trigger": "minecraft:using_item",
"conditions":
{
"item":
{
"items": "minecraft:book"
}
}
}
},
"rewards":
{
"function": "test:book"
}
}
The function:
advancement revoke @s only test:book
execute in overworld run tp @s 0 -60 0 0 0
playsound entity.player.teleport
What I expected to happen was:
The advancement stop trigger when release right mouse button.
What actually happened was:
The advancement keeps trigger and execute the reward function none-stop.
Steps to Reproduce:
1. Put the following datapack into your world and /reload
it.
2. Use the following command to get an edible book.
/give @s book[food={can_always_eat: true, eat_seconds: 86400, nutrition: 1, saturation: 1}]
3. Go to the nether.
4. In the nether, start using the book until you appear in the overworld.
5. You will be teleported back to the overworld, and stuck at (0, -60, 0) until you use the book again or switch to another hotbar slot.
Please note that the attached file is not a data pack, it is a zip file containing a data pack folder. I've taken the liberty to fix it for you.