Hi I have a realm and I want everyone to have an item that can teleport them home. I was thinking something like a feather that you hold for 3 seconds or maybe something that can activate instantly upon right-click? If you can help me please let me know how to do it or if it is even possible. Thanks
I know a way, but it maybe not what you are looking for. It is similar, but different. The way I have used for my game would be to detect if a player has an item in his inventory and if he/she does then the command wont activate, but if the player doesnt then it will activate. After the item has been dropped it would then give the player the item back.
/execute at @p unless entity @p[nbt={Inventory:[{id:"minecraft:Your item here"}]}]
Once the item has been dropped, it will activate this (repeat always active) command block and then you have a comparator following it with a redstone right after and then a command block (with what coding you want in it (impulse needs redstone)). After the 2nd block has been activated, you can give back the item with a simple command.
The @p will detect the closest player, so if you are able to then I suggest you try adding each player to a team or tag them and then editing the @p to @a[tag=...] @a[team=...].
I would recommend using the @a[tag=...] instead of team, as it will search all the players in the team and if any of them do have an item then it wont work. This is what I am using and I hope it helps.
Let me know if this worked, if it has and you are satisfied please edit your thread to [SOLVED].
1 problem i have is that i have to drop an item rather than using it and it also triggers even if i'm just moving the item from 1 slot to another. Maybe I could have a custom potion like Potion of Awakening and when you drink it, a command block detects your effect and teleports you to your bed as if you just woke up
I cant find or think of a solution around this. Unfortunately, this is the only solution of which I can provide as I cannot be sure what the commands are for checking status affect.
Hi I have a realm and I want everyone to have an item that can teleport them home. I was thinking something like a feather that you hold for 3 seconds or maybe something that can activate instantly upon right-click? If you can help me please let me know how to do it or if it is even possible. Thanks
I know a way, but it maybe not what you are looking for. It is similar, but different. The way I have used for my game would be to detect if a player has an item in his inventory and if he/she does then the command wont activate, but if the player doesnt then it will activate. After the item has been dropped it would then give the player the item back.
/execute at @p unless entity @p[nbt={Inventory:[{id:"minecraft:Your item here"}]}]
Once the item has been dropped, it will activate this (repeat always active) command block and then you have a comparator following it with a redstone right after and then a command block (with what coding you want in it (impulse needs redstone)). After the 2nd block has been activated, you can give back the item with a simple command.
The @p will detect the closest player, so if you are able to then I suggest you try adding each player to a team or tag them and then editing the @p to @a[tag=...] @a[team=...].
I would recommend using the @a[tag=...] instead of team, as it will search all the players in the team and if any of them do have an item then it wont work. This is what I am using and I hope it helps.
Let me know if this worked, if it has and you are satisfied please edit your thread to [SOLVED].
1 problem i have is that i have to drop an item rather than using it and it also triggers even if i'm just moving the item from 1 slot to another. Maybe I could have a custom potion like Potion of Awakening and when you drink it, a command block detects your effect and teleports you to your bed as if you just woke up
I cant find or think of a solution around this. Unfortunately, this is the only solution of which I can provide as I cannot be sure what the commands are for checking status affect.
Maybe execute if @e[type=player,nbt={ *potion effect here* }] run