TransWikia.com

How to test if an Armor Stand is missing a HandItem

Arqade Asked on January 29, 2021

I am using an armor stand to display items by using the following command:

/summon armor_stand ~0 ~5.1 ~-1.1 {Invisible:1b,Invulnerable:1b,NoBasePlate:1b,NoGravity:1b,ShowArms:1b,Rotation:[180f],Pose:{RightArm:[270f,0f,90f]}}

I usually give the armor stand a custom wooden shovel by hand. The custom wooden shovel is the following command:

 /give @p minecraft:wooden_shovel{display:{Name:"[{"text":"Ultimate Sniper","bold":true,"color":"gold"}]",},Enchantments:[{id:"mending",lvl:1}]} 1

Now what I want to do is to check if the armor stand is missing the wooden shovel from their hand, but I was not able to figure. I have tried the following command but it doesn’t check for the item, it only check for the existence of the armor stand.

execute if entity @e[type=armor_stand,limit=1,sort=nearest,nbt=!{TileX:-1532,TileY:153,TileZ:-279,HandItems:[{id:"minecraft:wooden_shovel"}]}] run say test

One Answer

So, I figured it out by myself. The solution was the following

execute as @e[x=-1532.5,y=153.6,z=-279,type=armor_stand,nbt={HandItems:[{id:"minecraft:wooden_shovel"}]}] run say test

Just use "as" instead of "if"

Answered by Firal on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP