So I was working on an item changing mob, based on range. Obviously this has been done before, I just wanted to try it out my own way.
But then I ran into a problem with a scoreboard I'm using that detects if the mob is holding an axe or a bow.
Here is the two summon commands:
/summon Skeleton ~ ~1 ~ {CustomName:"Uruk",Equipment:[{id:iron_axe,Count:1,tag:{ench:[{id:16,lvl:1},{id:32,lvl:2},{id:34,lvl:5}]}},{id:leather_boots,Count:1},{id:leather_leggings,Count:1,tag:{display:{color:5197647}}},{id:leather_chestplate,Count:1,tag:{display:{color:2368548}}},{id:skull,Damage:3,Count:1,tag:{display:{Name:Uruk Skull,Lore:["Wear it on your head...","To look fabulous."]},SkullOwner:{Id:"062667ed-7fe9-4680-8915-11e64a8a243c",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWFhZGY2MzZmNzI5NTQ2NGE0NjgyMTY5MjYxNDJkNGZiYmNiZDEyODNkZTc1YzM2NTUyYTM5MGI1NzNhMDYifX19"}]}}}}],DropChances:[0.85F,0.085F,0.085F,0.085F,0.8F]}
/summon Skeleton ~ ~1 ~ {CustomName:"Uruk",Equipment:[{id:bow,Damage:2,Count:1,tag:{ench:[{id:34,lvl:3},{id:48,lvl:2}]}},{id:leather_boots,Count:1},{id:leather_leggings,Count:1,tag:{display:{color:5197647}}},{id:leather_chestplate,Count:1,tag:{display:{color:2368548}}},{id:skull,Damage:3,Count:1,tag:{display:{Name:Uruk Skull,Lore:["Wear it on your head...","To look fabulous."]},SkullOwner:{Id:"062667ed-7fe9-4680-8915-11e64a8a243c",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWFhZGY2MzZmNzI5NTQ2NGE0NjgyMTY5MjYxNDJkNGZiYmNiZDEyODNkZTc1YzM2NTUyYTM5MGI1NzNhMDYifX19"}]}}}}],DropChances:[0.85F,0.085F,0.085F,0.085F,0.8F]}
Now the only thing in these two summon commands that are different is that one has a bow, and the other has the iron axe.
Afterwards I made the two scoreboard commands:
/scoreboard players set @e[name=Uruk] UrukItem 1 {Equipment:[{id:iron_axe,Count:1,tag:{ench:[{id:16,lvl:1},{id:32,lvl:2},{id:34,lvl:5}]}},{id:leather_boots,Count:1},{id:leather_leggings,Count:1,tag:{display:{color:5197647}}},{id:leather_chestplate,Count:1,tag:{display:{color:2368548}}},{id:skull,Damage:3,Count:1,tag:{display:{Name:Uruk Skull,Lore:["Wear it on your head...","To look fabulous."]},SkullOwner:{Id:"062667ed-7fe9-4680-8915-11e64a8a243c",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWFhZGY2MzZmNzI5NTQ2NGE0NjgyMTY5MjYxNDJkNGZiYmNiZDEyODNkZTc1YzM2NTUyYTM5MGI1NzNhMDYifX19"}]}}}}],DropChances:[0.85F,0.085F,0.085F,0.085F,0.8F]}
/scoreboard players set @e[name=Uruk] UrukItem 2 {Equipment:[{id:bow,Damage:2,Count:1,tag:{ench:[{id:34,lvl:3},{id:48,lvl:2}]}},{id:leather_boots,Count:1},{id:leather_leggings,Count:1,tag:{display:{color:5197647}}},{id:leather_chestplate,Count:1,tag:{display:{color:2368548}}},{id:skull,Damage:3,Count:1,tag:{display:{Name:Uruk Skull,Lore:["Wear it on your head...","To look fabulous."]},SkullOwner:{Id:"062667ed-7fe9-4680-8915-11e64a8a243c",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWFhZGY2MzZmNzI5NTQ2NGE0NjgyMTY5MjYxNDJkNGZiYmNiZDEyODNkZTc1YzM2NTUyYTM5MGI1NzNhMDYifX19"}]}}}}]}
But.... nothing's happening. I'm not sure what's wrong with it, or if anything is. Can someone try it out in their own world? It may just be me.
When accessing pre-existing data, you must test for it as it is stored. This means you're required to declare all tag-types and correctly check for string data (IDs are stored with the pack, such as "minecraft:bow" and not "bow").
As such, you should probably not be attempting to check for every single tag possible on the item since it becomes extremely complicated and results in heavy maintenance whenever you need to change a single value. What you should do instead is apply a custom tag to the item and only check for that tag. Any tag on items within the "tag" tag will not be removed, even if it's not a tag used by the game normally.
For example, the following summons a skeleton that's wearing an item that has a custom string tag called "ItemType", stating what type of item it's referring to:
Now when you apply the score, you only check for the "ItemType" value, which would essentially represent the item as a whole:
/scoreboard players set @e[name=Uruk] UrukItem 1 {Equipment:[{tag:{ItemType:"axe"}}]}
/scoreboard players set @e[name=Uruk] UrukItem 2 {Equipment:[{tag:{ItemType:"bow"}}]}
Implementing the tags into your own /summon commands:
/summon Skeleton ~ ~1 ~ {CustomName:"Uruk",Equipment:[{id:iron_axe,Count:1,tag:{ItemType:"axe",ench:[{id:16,lvl:1},{id:32,lvl:2},{id:34,lvl:5}]}},{id:leather_boots,Count:1},{id:leather_leggings,Count:1,tag:{display:{color:5197647}}},{id:leather_chestplate,Count:1,tag:{display:{color:2368548}}},{id:skull,Damage:3,Count:1,tag:{display:{Name:Uruk Skull,Lore:["Wear it on your head...","To look fabulous."]},SkullOwner:{Id:"062667ed-7fe9-4680-8915-11e64a8a243c",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWFhZGY2MzZmNzI5NTQ2NGE0NjgyMTY5MjYxNDJkNGZiYmNiZDEyODNkZTc1YzM2NTUyYTM5MGI1NzNhMDYifX19"}]}}}}],DropChances:[0.85F,0.085F,0.085F,0.085F,0.8F]}
/summon Skeleton ~ ~1 ~ {CustomName:"Uruk",Equipment:[{id:bow,Damage:2,Count:1,tag:{ItemType:"bow",ench:[{id:34,lvl:3},{id:48,lvl:2}]}},{id:leather_boots,Count:1},{id:leather_leggings,Count:1,tag:{display:{color:5197647}}},{id:leather_chestplate,Count:1,tag:{display:{color:2368548}}},{id:skull,Damage:3,Count:1,tag:{display:{Name:Uruk Skull,Lore:["Wear it on your head...","To look fabulous."]},SkullOwner:{Id:"062667ed-7fe9-4680-8915-11e64a8a243c",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWFhZGY2MzZmNzI5NTQ2NGE0NjgyMTY5MjYxNDJkNGZiYmNiZDEyODNkZTc1YzM2NTUyYTM5MGI1NzNhMDYifX19"}]}}}}],DropChances:[0.85F,0.085F,0.085F,0.085F,0.8F]}
The /scoreboard commands will remain the same as above.
So I was working on an item changing mob, based on range. Obviously this has been done before, I just wanted to try it out my own way.
But then I ran into a problem with a scoreboard I'm using that detects if the mob is holding an axe or a bow.
Here is the two summon commands:
Now the only thing in these two summon commands that are different is that one has a bow, and the other has the iron axe.
Afterwards I made the two scoreboard commands:
But.... nothing's happening. I'm not sure what's wrong with it, or if anything is. Can someone try it out in their own world? It may just be me.
When accessing pre-existing data, you must test for it as it is stored. This means you're required to declare all tag-types and correctly check for string data (IDs are stored with the pack, such as "minecraft:bow" and not "bow").
Now when you apply the score, you only check for the "ItemType" value, which would essentially represent the item as a whole:As such, you should probably not be attempting to check for every single tag possible on the item since it becomes extremely complicated and results in heavy maintenance whenever you need to change a single value. What you should do instead is apply a custom tag to the item and only check for that tag. Any tag on items within the "tag" tag will not be removed, even if it's not a tag used by the game normally.
For example, the following summons a skeleton that's wearing an item that has a custom string tag called "ItemType", stating what type of item it's referring to:
Implementing the tags into your own /summon commands:
The /scoreboard commands will remain the same as above.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/