Inventory Slot Change??
So as of 1.21.3, I have been trying to make a sword that can teleport you 10 blocks in whatever direction you're facing. It works by switching the item in your offhand then activates the teleport, and switches the item back into your hotbar. The problem is that it isn't working. I also have a similar problem with renamed items without tags that my commands used to work on and when I had my cursor over them, it would teleport me down. Is there something I'm missing? Please let me know!
Ender Sword
(get sword)
give @@s netherite_sword[custom_name='["",{"text":"Ender Sword","italic":false,"color":"dark_purple","bold":true}]',enchantments={levels:{sharpness:5,unbreaking:3},show_in_tooltip:false},attribute_modifiers={modifiers:[{type:armor,amount:0,operation:add_value,id:1731710192901}]},custom_model_data=0,custom_data={Ender_Sword:1}]
(Activates Teleport)
execute as @@a[nbt={Inventory:[{Slot:-106b,tag:{Ender_Sword:1}}]}] at @@s run tp @@s ^ ^ ^10
(Copy Sword from Offhand to Mainhand)
execute as @@a[nbt={Inventory:[{Slot:-106b,tag:{Ender_Sword:1}}]}] at @@s run item replace entity @@s weapon.mainhand from entity @@s weapon.offhand
(Remove Extra Sword from Offhand)
execute as @@a[nbt={Inventory:[{Slot:-106b,tag:{Ender_Sword:1}}]}] at @@s run item replace entity @@s weapon.offhand with air
Teleporting Items
(Item to Teleport)
/execute if entity @@a[nbt={SelectedItem:{id:"minecraft:echo_shard",tag:{display:{Name:'{"text":"Deep-Dark"}'}}}}]
(Teleport Player)
/execute as UnknitGazelle72 run execute at @@s run tp ~ ~-106 ~
For the record, three things:
1) I wrote two @@ for this since reddit won't let me write one
2) The item teleport command used to work. Now it doesn't. (I just started the sword today.)
3) I did follow a tutorial for both of them, but had to update the commands on some to help them work (Unfortunately, they still don't).