0

For context, I don't think the riptide enchantment gives a player enough speed or distance underwater. I mostly wanted to use it for fast water travel without a boat. I've found that giving a player dolphin's grace gives me the experience I'm looking for. Unfortunately, I've found that only giving the effect to players using the item is impossible, so I want to give the effect to any player holding a riptide 3 trident. I've written the following command to execute this:

execute as @a[nbt={SelectedItem:{id:"minecraft:trident",tag:{Enchantments:[{id:riptide,lvl:3}]}}}] run effect give @s minecraft:dolphins_grace 1

And I've put it in a repeating, unconditional, always active command block, yet I don't get the effect when I hold the trident. Additionally, I also want this to work when other enchantments are used alongside riptide 3, but I'm not sure the command above would work if e.g. mending and riptide 3 are added to a trident.

Could anyone tell me why my command doesn't work, if this would work for additional enchantments, and if not, how to fix that?

7
  • If I get the command working as intended, I'm planning to put it into a datapack. If anyone is interested in using the datapack for themselves, let me know, then I'll upload it to GitHub and post a link.
    – HYBR1D
    Commented Mar 16, 2022 at 3:55
  • 2
    Possible duplicate of Testforblock finds an item I have summoned, but not one I made
    – pppery
    Commented Mar 16, 2022 at 14:20
  • The command syntax has changed quite a lot over the minecraft versions. For example, item ids are no longer valid. I don't think this post applies well enough to count as an answer for MC 1.18.2.
    – HYBR1D
    Commented Mar 16, 2022 at 16:20
  • It is part of the policy of this site that we expect old questions to be kept up to date rather than re-asked with each change to relevant syntax.
    – pppery
    Commented Mar 16, 2022 at 16:30
  • 1
    @pppery That may be true, but it's not right to close it until after the question has been updated with the new information, or until it is confirmed that the existing answers convey sufficient detail to answer this one even as outdated. Otherwise people are left with a dead end to find their answers. If you are going to VTC, I invite you to update the existing answer. If you're unwilling or unable to update, let someone more knowledgeable update the answer before voting.
    – One 2 Many
    Commented Mar 16, 2022 at 17:48

1 Answer 1

2

Turns out one character made the difference:

execute as @a[nbt={SelectedItem:{tag:{Enchantments:[{id:"minecraft:riptide",lvl:3s}]}}}] run effect give @s dolphins_grace 1

Apparently, enchantment levels need to be indicated with the letter s behind them.

Also, the command to works fine with additional enchantments, in a singleplayer world. On my PaperMC server, however, additional enchantments make the command fail to register. I'm looking for a way to get around this. Worst case, I have to add all possible combinations of enchantments including riptide.

Not the answer you're looking for? Browse other questions tagged or ask your own question.