1
So I am working on a data pack that adds some custom items. I want to make it so that when you where a spider head, you get night vision, but when I put the head on, nothing happens.
The Spider Head Command:
/give @p player_head{SkullOwner:MHF_Spider,display:{Name:'[{"text":"Spider Head","italic":false,"color":"dark_red"}]',Lore:['[{"text":"The head of a spider, which","italic":false}]','[{"text":"grants night vision to the","italic":false}]','[{"text":"wearer.","italic":false}]']},Enchantments:[{id:thorns,lvl:1}],HideFlags:1} 1
The Execute command in "tick":
execute as @a[nbt={Inventory:[{Slot:103b,id:"minecraft:player_head",tag:{SkullOwner:MHF_Spider,display:{Name:'[{"text":"Spider Head","italic":false,"color":"dark_red"}]',Lore:['[{"text":"The head of a spider, which","italic":false}]','[{"text":"grants night vision to the","italic":false}]','[{"text":"wearer.","italic":false}]']},Enchantments:[{id:thorns,lvl:1}],HideFlags:1}}]}] run effect give @s minecraft:night_vision 1 2 true
No errors are given when loading the pack, and the spider head works as it should.
The Spider Head Command:
/give @p player_head{SkullOwner:MHF_Spider,display:{Name:'[{"text":"Spider Head","italic":false,"color":"dark_red"}]',Lore:['[{"text":"The head of a spider, which","italic":false}]','[{"text":"grants night vision to the","italic":false}]','[{"text":"wearer.","italic":false}]']},Enchantments:[{id:thorns,lvl:1}],HideFlags:1} 1
The Execute command in "tick":
execute as @a[nbt={Inventory:[{Slot:103b,id:"minecraft:player_head",tag:{SkullOwner:MHF_Spider,display:{Name:'[{"text":"Spider Head","italic":false,"color":"dark_red"}]',Lore:['[{"text":"The head of a spider, which","italic":false}]','[{"text":"grants night vision to the","italic":false}]','[{"text":"wearer.","italic":false}]']},Enchantments:[{id:thorns,lvl:1}],HideFlags:1}}]}] run effect give @s minecraft:night_vision 1 2 true
No errors are given when loading the pack, and the spider head works as it should.
Create an account or sign in to comment.
3
Give the spider head a tag of CustomHead:1b, then you only have to check for the CustomHead:1b tag.
Create a predicate that checks for a player head in the head slot. To differentiate between different player heads, use a tag such as CustomModelData.
Heres an example:
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:player_head"
],
"nbt": "{CustomModelData:1}"
}
}
}
}
Heres an example:
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:player_head"
],
"nbt": "{CustomModelData:1}"
}
}
}
}
Don't search for huge tags like that. Use a single custom arbitrary NBT tag and test for that instead.