im trying to use commands to make a robot that basically just picks up items you throw at it and you can take them back later on. is this possible? how could i make this happen?
I would use /data to copy the item into the armor stand's hand and then remove the ground item. Armor stands have an NBT tag called HandItems which contains the data of all held items. This is how you can copy an item to its hand:
/execute as @e[tag=armor_stand] at @s unless data entity @s HandItems[0].Items run data modify entity @s HandItems[0] set from entity @e[type=item,limit=1,sort=nearest] Item
im trying to make it so if the main hand already has an item, it will put other items in the offhand so it can hold two items at once, but for some reason the offhand wont pick anything up. here are the commands im running:
repeating, unconditional, always active
execute as @e[tag=robo4] at @s unless data entity @s HandItems[0].Items unless data entity @s HandItems[1].Items run data modify entity @s HandItems[0] set from entity @e[type=item,limit=1,sort=nearest,distance=..1.5] Item
chain, conditional, always active
execute as @e[tag=robo4] at @s run kill @e[type=item,limit=1,sort=nearest,distance=..1.5]
repeating, unconditional, always active
execute as @e[tag=robo4] at @s if data entity @s HandItems[0].Items unless data entity @s HandItems[1].Items run data modify entity @s HandItems[1] set from entity @e[type=item,limit=1,sort=nearest,distance=..1.5] Item
chain, conditional, always active
execute as @e[tag=robo4] at @s run kill @e[type=item,limit=1,sort=nearest,distance=..1.5]
i cant figure out what the problem is. also, is there a way to make it drop the items somehow?
HandItems[0].Items is not a tag. You should be testing for either HandItems[0].id or HandItems[0].Count. Run this command near the armor stand (while it's holding an item) to see what I mean:
/data get entity @e[type=minecraft:armor_stand,limit=1,sort=nearest] HandItems[0]
Also, your first commands should only be checking if slot 0 is available.
As for dropping the items, it's the same as picking them up but in reverse.
/execute at @e[tag=robo4] run summon item ~ ~ ~ {Item:{id:"minecraft:paper",Count:1},Tags:["copy"]}
/execute as @e[tag=robo4] at @s run data modify entity @e[tag=copy,limit=1,sort=nearest] Item set from entity @s HandItems[0]
im trying to use commands to make a robot that basically just picks up items you throw at it and you can take them back later on. is this possible? how could i make this happen?
I would use /data to copy the item into the armor stand's hand and then remove the ground item. Armor stands have an NBT tag called HandItems which contains the data of all held items. This is how you can copy an item to its hand:
Command block engineer // Developer // #TeamTrees
im trying to make it so if the main hand already has an item, it will put other items in the offhand so it can hold two items at once, but for some reason the offhand wont pick anything up. here are the commands im running:
i cant figure out what the problem is. also, is there a way to make it drop the items somehow?
HandItems[0].Items is not a tag. You should be testing for either HandItems[0].id or HandItems[0].Count. Run this command near the armor stand (while it's holding an item) to see what I mean:
Also, your first commands should only be checking if slot 0 is available.
As for dropping the items, it's the same as picking them up but in reverse.
Command block engineer // Developer // #TeamTrees
i was trying to make it so it could pick up a second item in the offhand, but its not really necessary. thank you!!
It should work for the offhand as well. I used your commands when testing, and both slots worked after I applied the changes.
Command block engineer // Developer // #TeamTrees