You can add a cooldown to the teleport so the player has time to leave the teleport area.
This tutorial shows the idea. The commands are in the description so you can easily copy them from there. It's an old video but I believe all the commands should still work in the newer versions.
Episode 57: A two way teleporter using a cooldown to stop the player getting caught in an infinite teleporting loop:
A repeating command to assign all players an id if they don't already have one
execute as @a unless score @s id = @s id store result score @s id run scoreboard players add #id_holder id 1
Lastly a repeating chain to teleport the player to their trident if it is in the ground and more than 5 blocks away:
1: Copy the players ID to the nearest trident that doesn't have an ID, if that player has just thrown a tagged trident.
execute as @a[scores={used_trident=1}] at @s as @e[type=trident, sort=nearest, limit=1, nbt={Trident:{tag:{my:trident}}}] unless score @s id = @s id run scoreboard players operation @s id = @a[distance=..0.1] id
2: Teleport the player to any trident that is in the ground and has the same ID as the player.
execute as @e[type=trident, nbt={inGround:true, Trident:{tag:{my:trident}}}] at @s as @a[distance=5..] if score @s id = @e[type=trident, distance=..0.1, nbt={Trident:{tag:{my:trident}}}, limit=1] id run tp @s[tag=!dev] @e[type=trident, distance=..0.1, nbt={Trident:{tag:{my:trident}}}, limit=1]
3: Reset the players score.
scoreboard players reset @a used_trident
This may not be exactly what you want, but hopefully it will help a bit.
I am guessing you asked this question on Minecraft Commands Reddit as well, since it's almost identical.
In case it wasn't you, here is the answer from GalSergey that was given there.
Do not try to check the item name, this check often fails. Use a custom tag for this, here's an example:
Item example:
give @s spruce_stairs{Test:true}
Command block
execute positioned 22 115 7 as @e[type=item,distance=..1,nbt={Item:{tag:{Test:true}}}] run say Example Command.
Testing using a name can be tricky since Minecraft likes to reorder the data about the name causing the command to fail even though it looks ok.
Better to give the head a custom tag and check for that.
Give player head:
give @p player_head{customTag:true}
Check for tagged item in head slot:
effect give @a[nbt={Inventory:[{Slot:103b, tag:{customTag:true}}]}] minecraft:health_boost 1 9 true
Checking the NBT of the player every tick is not great for performance so you may want to run checks like this every 1 or 2 seconds instead of 20 times a second.
Also worth noting that when you charge above 64 emeralds for something it will auto discount to 64 since you can't have a larger stack than that. You could probably charge them 64 and 26 emeralds to make 90 like in the recipe below:
Yes, first you will need a dummy objective called "amount".
scoreboard objectives add amount dummy
Then you have the three command blocks in a chain:
Repeat Active: Put the number of players into objective
Chain Unconditional Active: Check the score and run a command
Chain Unconditional Active: Reset the fake players score
It later versions you could put an interaction entity just in front of the door, so the player is not actually clicking the door, but the interaction entity. Then get that to say or run whatever you want when clicked on. Java 1.19.4 and higher have the interaction entity: https://minecraft.fandom.com/wiki/Interaction
In earlier versions you could maybe check to see if the door is open, and if it is then shut it with commands and say whatever you want. This may well look a bit janky though.
If you are using a Datapack I'm pretty sure you could set up a custom item tag called #everything and put the id of every item that can have "the_tag:1" in there. Then use the following in game:
0
You can add a cooldown to the teleport so the player has time to leave the teleport area.
This tutorial shows the idea. The commands are in the description so you can easily copy them from there. It's an old video but I believe all the commands should still work in the newer versions.
Episode 57: A two way teleporter using a cooldown to stop the player getting caught in an infinite teleporting loop:
1
I believe that in 1.21 the folders have been renamed. Try changing the folder name from "functions" to "function".
Here is the changelog in case it helps: https://www.minecraft.net/en-us/article/minecraft-java-edition-1-21#:~:text=TAGS-,DIRECTORY RENAMES,-Some registry types
0
Hello, not sure what version you are in, but here is something in 1.19.4
First give the player the trident with a custom tag, using the name to target things can often break.
Next set up some scores:
A repeating command to assign all players an id if they don't already have one
Lastly a repeating chain to teleport the player to their trident if it is in the ground and more than 5 blocks away:
1: Copy the players ID to the nearest trident that doesn't have an ID, if that player has just thrown a tagged trident.
2: Teleport the player to any trident that is in the ground and has the same ID as the player.
3: Reset the players score.
This may not be exactly what you want, but hopefully it will help a bit.
1
Which version are you in?
What item are you holding when you activate the command block?
It looks like you are trying to enchant an item that can't have the sharpness enchantment.
In 1.19.4 if I put the following command into a command block and activate it while holding a sword then it works:
0
I am guessing you asked this question on Minecraft Commands Reddit as well, since it's almost identical.
In case it wasn't you, here is the answer from GalSergey that was given there.
Do not try to check the item name, this check often fails. Use a custom tag for this, here's an example:
Item example:
Command block
0
Testing using a name can be tricky since Minecraft likes to reorder the data about the name causing the command to fail even though it looks ok.
Better to give the head a custom tag and check for that.
Give player head:
Check for tagged item in head slot:
Checking the NBT of the player every tick is not great for performance so you may want to run checks like this every 1 or 2 seconds instead of 20 times a second.
0
Does this work?
0
Invulnerable won't stop it coming off the wall if it's inside a block, you can use the Fixed property:
This will make the nearest item frame to where the command was ran be Fixed. It won't break even if the block it's on is broken.
0
Tested in: Java 1.20.1 (But should work in some earlier versions as well.)
There was a few errors in there. This should work:
Also worth noting that when you charge above 64 emeralds for something it will auto discount to 64 since you can't have a larger stack than that. You could probably charge them 64 and 26 emeralds to make 90 like in the recipe below:
When making commands like this, https://mcstacker.net/ can be quite helpful.
0
Yes, first you will need a dummy objective called "amount".
Then you have the three command blocks in a chain:
Repeat Active: Put the number of players into objective
Chain Unconditional Active: Check the score and run a command
Chain Unconditional Active: Reset the fake players score
Hope that helps
0
You could save the amount of players in survival to a score and then check the score:
Put number of players in Survival in to a scoreboard objective called amount on a fake player:
Check if the score is 1 and run a command if it is:
Reset the fake players score:
0
The z motion is detected from further away. Is it getting pushed out of range before the x motion can be done?
is saying: Run this command unless this entity exists, which it does, so that code doesn't run.Or maybe the:
Things to try:
Changing the distance for the x check to match the z check, or
Remove this: from the beginning of line 1 and 3
0
It later versions you could put an interaction entity just in front of the door, so the player is not actually clicking the door, but the interaction entity. Then get that to say or run whatever you want when clicked on. Java 1.19.4 and higher have the interaction entity: https://minecraft.fandom.com/wiki/Interaction

In earlier versions you could maybe check to see if the door is open, and if it is then shut it with commands and say whatever you want. This may well look a bit janky though.
0
I'm not sure, but I would guess the more items in there, the more there is to check, so it would be slower. As I said, complete guess.
1
If you are using a Datapack I'm pretty sure you could set up a custom item tag called #everything and put the id of every item that can have "the_tag:1" in there. Then use the following in game: