Hey there. What I'm trying to do is /testfor a specific item actively being held by the player. If it is, then clear that item out and give the player a different item. I have been able to do everything except for detect if the player is ACTIVELY holding the item. No matter what slot the item is in, it always gets replaced. Here are the three commands that I'm currently using:
/testfor @a {SelectedItem:{id:"minecraft:nether_brick",Count:1b,tag:{display:{Name:"Ballpoint Pen",Lore:["It's a capped pen..."]},HideFlags:3,ench:[{id:51,lvl:1}]}},SelectedItemSlot:0}
/give @p[c=1] minecraft:diamond_sword 1 0 {display:{Name:"Riptide",Lore:["A blade with a long and tragic history"]},HideFlags:2,Unbreakable:1b,ench:[{id:16,lvl:6},{id:61,lvl:10}],AttributeModifiers:[{AttributeName:"generic.attackSpeed",Name:"generic.attackSpeed",Amount:6,Operation:0,UUIDLeast:218741,UUIDMost:170313}]}
The first command block is set as Repeat-Unconditional-Always Active
The second command block is set as Chain-Unconditional-Requires Redstone
The third command block is set as Chain-Conditional-Requires Redstone
Have you tried setting the second command block to conditional? It should only cast if the testfor is successful.
What might be happening is the second chain CB is casting regardless of the outcome of the first. The fact the first is being activated at all should mean that the second will be activated regardless which means your 3rd block is soon to follow.
Hey there. What I'm trying to do is /testfor a specific item actively being held by the player. If it is, then clear that item out and give the player a different item. I have been able to do everything except for detect if the player is ACTIVELY holding the item. No matter what slot the item is in, it always gets replaced. Here are the three commands that I'm currently using:
/testfor @a {SelectedItem:{id:"minecraft:nether_brick",Count:1b,tag:{display:{Name:"Ballpoint Pen",Lore:["It's a capped pen..."]},HideFlags:3,ench:[{id:51,lvl:1}]}},SelectedItemSlot:0}
/clear @a netherbrick 0 1 {display:{Name:"Ballpoint Pen"}}
/give @p[c=1] minecraft:diamond_sword 1 0 {display:{Name:"Riptide",Lore:["A blade with a long and tragic history"]},HideFlags:2,Unbreakable:1b,ench:[{id:16,lvl:6},{id:61,lvl:10}],AttributeModifiers:[{AttributeName:"generic.attackSpeed",Name:"generic.attackSpeed",Amount:6,Operation:0,UUIDLeast:218741,UUIDMost:170313}]}
The first command block is set as Repeat-Unconditional-Always Active
The second command block is set as Chain-Unconditional-Requires Redstone
The third command block is set as Chain-Conditional-Requires Redstone
Any help would be GREATLY appreciated. Thanks.
Have you tried setting the second command block to conditional? It should only cast if the testfor is successful.
What might be happening is the second chain CB is casting regardless of the outcome of the first. The fact the first is being activated at all should mean that the second will be activated regardless which means your 3rd block is soon to follow.