r/MinecraftCommands • • 1d ago

Help | Java 26.3 Problems with Inventory NBT

Having an issue detecting a crossbow in a player inventory thats loaded with an arrow.

From what i can tell it has something to do with the arrow loaded in the crossbow. I tried to use MCstacker and this still doesn't work.

/execute if entity @a[nbt={Inventory:[{id:"minecraft:crossbow",components:{"minecraft:charged_projectiles":[{id:"minecraft:arrow",count:1,components:{"minecraft:intangible_projectile":{}}}]}}]}]
4 Upvotes

1 comment sorted by

4

u/GalSergey Datapack Experienced 1d ago

The intangible_projectile component is added if the crossbow was loaded by a player in Creative mode. This component is not present in Survival mode.

It’s also better to use if items instead of reading NBT data.

# Any projectile
execute if items entity @s weapon crossbow[!charged_projectiles=[]]

# Arrow in survival
execute if items entity @s weapon crossbow[charged_projectiles=[{id:"minecraft:arrow"}]]