1

Help with some commands....

Flashbulb 12/24/21 12:33 pm
143
1/2/2022 4:55 am
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.
Posted by
Flashbulb
Level 54 : Grandmaster Fish Fish
110

  Have something to say?

JoinSign in

3

Silabear
01/02/2022 4:55 am
He/Him • Level 70 : Legendary Guard Bear
Give the spider head a tag of CustomHead:1b, then you only have to check for the CustomHead:1b tag.
1
Spuduking
01/02/2022 12:09 am
Level 34 : Artisan Procrastinator
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}"
    }
    }
  }
}
1
WhoAteMyButter
12/27/2021 12:05 am
Level 42 : Master System
Don't search for huge tags like that. Use a single custom arbitrary NBT tag and test for that instead.
1

Welcome