#Item name check not working

1 messages · Page 1 of 1 (latest)

outer wedge
#

This funny bit of code here works without the name. once i ask for the name of the item, it no longer works. any ideas? thanks

if victim's leggings are iron leggings with name "§bDivertive Slacks": if victim is sneaking: chance of 100%: cancel event play sound "entity.armor_stand.hit" with volume 0.5 at location of victim

dark burrow
#

try if victim's leggings is iron leggings named "§bDivertive Slacks":

outer wedge
#

that doesn't change anything.

rich birch
#
  1. Are you sure that is the name? No typos/incorrect colour codes or other formatting? (it happens)
  2. That code will check for undamaged, unenchanted, iron leggings. They have to be clean, unmodified, except for the attributes you specify within the code, which in this case is only a name. So if the item has < 100% durability, or some enchantments, the condition will fail.
  • this is why the best option is to set a custom NBT tag and then check for that
outer wedge
#

it works when i check for clean iron leggings. the armor has more than just name, but it still works. there is also no formating issues, as the name of the item is taken directly from the code

rich birch
#

you can just check the name

#

(name of player's leggings) = "..."

outer wedge
#

this worked

outer wedge
#

so i got another situation of this. Ive tried both of these things

set {_i} to leather chestplate named "§fPyrolinen Tunic" with lore "§7Grants Moderate Fire Protection" add nbt compound of "{Trim:{pattern:dune,material:redstone},Unbreakable:1,display:{color:11546150},Enchantments:[{lvl:2,id:fire_protection}],AttributeModifiers:[{AttributeName:""generic.armor"",Amount:3,Slot:chest,Name:""generic.armor"",UUID:[I;-124423,23576,18315,-47152]}],HideFlags:192}" to nbt compound of {_i} if player has {_i}: set {_Afford} to "§6" else: set {_Afford} to "§c"

if player has leather chestplate named "§fPyrolinen Tunic": set {_Afford} to "§6" else: set {_Afford} to "§c"

rich birch
#

i would use an NBT tag for this

outer wedge
#

?

rich birch
#

give it a custom nbt tag, then check for that

outer wedge
#

is that not what i am doing

rich birch
#

no, you're checking if player has {_i}. {_i} is the exact item as you defined it. Meaning it needs to have no extra enchantments, full durability, non-dyed, etc.

outer wedge
#

even if i define all those characteristics?

rich birch
#

well, you could, but then a player could go dye it blue and the code breaks again

outer wedge
#

so then how come its not working because i have ever single characteristic defined and the item is identical to what is there

rich birch
#

try player's inventory contains ...

#

but also you can broadcast the full NBT to see if it really is exactly the same

outer wedge
#

oh wow, there is a whole bunch of other garbage tags. can you explain the nbt tags and how to add them and identify them

rich birch
outer wedge
#

ok so this is still way over my head, is there a way i could this just checking the inventory for an item with name "§fPyrolinen Tunic"

rich birch
#

yes

outer wedge
#

What is the syntax for that?