1

Detecting tags on items problem

1 emeralds2 replies29 views
HeadBodyScript started 5/17/21 2:29 pm
and replied 5/17/2021 5:29 pm
I am making a weapon system but I ran into a problem that I am unable to fix myself because I don't know why it's not working

I need my item (A crossbow) to have 2 tags: "Weapon" and "Glock"

These tags will be needed to identify what the player is holding during sertain interactions

My example that doesn't work for me:

give @p minecraft:crossbow{Tag:"Weapon,Glock",Unbreakable:1,display:{Name:'[{"text":"Glock-18-Tactical","italic":false}]',Lore:['[{"text":"12 ROUND","italic":false,"color":"red"},{"text":"","italic":false,"color":"dark_purple"}]','[{"text":"Medium Damage","italic":false,"color":"gray"}]','[{"text":"Low Range","italic":false,"color":"gray"}]']},HideFlags:4,Charged:1,ChargedProjectiles:[{id:"minecraft:arrow",Count:1}]}

This gives a loaded weapon with details of what the weapon is
The problem is that the Tag:"Weapon,Glock" part makes it not work in a command block when I try to detect it with

execute as @a[​tag=Player1] if score @s Ammo1.2 matches 1 run replaceitem entity @s[​nbt={SelectedItem:{tag:{Tag:"Weapon,Glock"}}},nbt={SelectedItem:{tag:{display:{Name:'{"text":"Glock-18-Standard"}'},Charged:0b}}}] weapon.mainhand minecraft:crossbow{Enchantments:[{id:piercing,lvl:1}],display:{Name:'{"text":"Glock-18-Standard"}'},Charged:1,ChargedProjectiles:[{id:"minecraft:arrow",Count:1}]}


If needed I can talk about it on discord and show you in a call to explain it better. (I am bad at explaining so sorry)


If this is fixed or even possible so many problems will be fixed so any help is appreciated
Posted by avatar
HeadBodyScript
Level 17 : Journeyman System
8

Create an account or sign in to comment.

2 replies

2
05/17/2021 3:04 pmhistory
Level 62 : High Grandmaster Cyborg
Bertiecrafter
Bertiecrafter avatar
Isn't the whole point of having tags that you don't have to detect display names?
Try replacing the tag with an array and then detect based on one entry. Also since it's a gun, I took the liberty to add the tags to the resulting item as well so that the bow gets reloaded with every shot:
give @p minecraft:crossbow{Tags:["Weapon","Glock-18-Tactical"],Unbreakable:1,display:{Name:'[{"text":"Glock-18-Tactical","italic":false}]',Lore:['[{"text":"12 ROUND","italic":false,"color":"red"},{"text":"","italic":false,"color":"dark_purple"}]','[{"text":"Medium Damage","italic":false,"color":"gray"}]','[{"text":"Low Range","italic":false,"color":"gray"}]']},HideFlags:4,Charged:1,ChargedProjectiles:[{id:"minecraft:arrow",Count:1}]}
execute as @a[​tag=Player1] if score @s Ammo1.2 matches 1 run replaceitem entity @s[​nbt={SelectedItem:{tag:{Tags:["Glock-18-Tactical"],Charged:0b}}}] weapon.mainhand minecraft:crossbow{Tags:["Glock-18-Tactical"],Enchantments:[{id:piercing,lvl:1}],display:{Name:'{"text":"Glock-18-Standard"}'},Charged:1,ChargedProjectiles:[{id:"minecraft:arrow",Count:1}]}
I put the first one in a command block to get myself the item and the other one in a repeating command block and it worked. Sooooo it should work in a data pack as well. If it doesn't work, just try simplifying the command until it does work and then fix bugs and slowly make it more complex.

(I didn't test with the tag and score check in the beginning, but you can quite quickly figure out if they should pass with /tag list and /scoreboard players get)
2
05/17/2021 5:29 pm
Level 17 : Journeyman System
HeadBodyScript
HeadBodyScript avatar
Ok it took me a while but ty so much, it was way too confusing and I was like ????? But you helped a lot <3

I got it fully working now ty ty
Planet Minecraft

Website

© 2010 - 2021
www.planetminecraft.com

Welcome