So with the /effect command, it can give either you or a random entity in Minecraft. However, you can actually make custom items in the game with effects when you wear it, here:
So I want to make armor with resistance 255 so it would make you immortal, and pls put the command that you need to have armor with a custom nametag so the effect you appear and that's by using the "tag" command, thank you.
01 Answer
The tag command could be used but then the item needs to be placed on the ground to apply the tag to the item, it's better to directly apply a tag to the item with the Tags:[""] parameter.
By using this command:
execute as @a if entity @s[nbt={Inventory:
[{Slot:102b,id:"minecraft:iron_chestplate",tag:
{Tags:["Immortal"],display:{Name:"{\"text\":\"Immortal Chestplate\"}"}}}]}]
run effect give @s resistance 1 255You will give all players that wear a chest plate named Immortal Chestplate and if the chest plate has the tag Immortal, resistance 255 for 1 sec. This will only affect any player that actually has the correct item, i.e. the name and the tag needs to match.
Place this in a command block with Repeat Unconditional Always Active.
This command will place an immortal chestplate on a player(in the chest slot):
/replaceitem entity @p armor.chest minecraft:iron_chestplate{Tags:["Immortal"],
display:{Name:"{\"text\":\"Immortal Chestplate\"}"}}Then with the give command:
/give @p iron_chestplate{Tags:["Immortal"],display:{Name:"{\"text\":\"Immortal Chestplate\"}"}}Using the summon command:
/summon item ~ ~ ~ {Item:{id:"minecraft:iron_chestplate",Count:1,tag:
{Tags:["Immortal"],display:{Name:"{\"text\":\"Immortal Chestplate\"}"}}}}If you want to test for a helmet you change the number at Slot:102b to 103:b, leggings for 101b, and boots for 100b.
Note
replaceitem will be replaced with the item command in 1.17, the difference is that you need to add replace before the item:
/replaceitem entity @p armor.chest iron_chestplate{}becomes
/item entity @p armor.chest replace iron_chestplate{} 0