As of 14w10c, this is possible using scoreboard values.
First, you need to set up a dummy scoreboard variable. I used "sneaky" as my variable, but you can really use whatever you want (as long as you change the commands as appropriate). To set this up, you just need to use the command /scoreboard objectives add sneaky dummy
. You only need to do this once.
I had to set up the command blocks in a very specific pattern for them to work, as shown:
I think this has something to do with how command blocks handle firing off "simultaneously". The comparator in this setup is in subtraction mode, creating a "comparator clock" which pulses very quickly.
The command blocks on the left are your scoreboard related commands. The one on the bottom left sets "sneaky" to 0 for all players:
/scoreboard players set @a sneaky 0
The command block on the top left sets "sneaky" to 1 for all players with the stealth boots equipped:
/scoreboard players set @a sneaky 1 {Inventory:[{Slot:100b,tag:{display:{Name:"Stealth Boots"}}}]}
The command blocks on the right are your effect commands. They give players the invisibility effect, or take it away, as appropriate. The one on the bottom clears the invisibility effect from all players without the stealth boots:
/effect @a[score_sneaky=0] 14 0 0
The top one gives the invisibility effect to all players with the stealth boots:
/effect @a[score_sneaky_min=1] 14 30000
Now I'm not a genius when it comes to command blocks so I can't tell you what is wrong but I remade your command and tested it in 1.9.2 (which worked) and by comparing my command and your command there is some differences.
/summon Villager ~ ~1 ~ {CustomName:"The First Wizard",CustomNameVisible:1,Profession:1,Career:1,CareerLevel:42,Offers:{Recipes:[{rewardExp:0b,maxUses:2147483647,uses:0,buy:{id:emerald,Count:1},sell:{id:potion,Count:1,tag:{display:{Name:"Super Potion"},CustomPotionEffects:[{Id:5,Amplifier:5,Duration:600}]}}}]},Attributes:[{Name:generic.movementSpeed,Base:0}],Invulnerable:1,PersistenceRequired:1,Silent:1}
The generator I made this with is
http://mcstacker.bimbimma.com/
It might be a bit confusing at first but it helps me make several of my commands. It even gives a description for all/most of the options it gives.
Hopes this helps!
Best Answer
The issue with checking for the
Count
tag is that it checks for an exact match rather than minimum. The player must have a stack of exactly 2 emeralds in a slot in their inventory, otherwise they cannot match.To circumvent that, you will have to use CommandStats, which are a set of triggers that can set a target's scoreboard score based on the success of the command. For example, the "SuccessCount" trigger sets a score equal to the number of times a command was successfully processed (such as
/testfor @e[type=Creeper]
resulting in a score equal to the number of creepers).For item detection, "AffectedItems" will be used.
Prerequisites
Objective to hold each player's "AffectedItems" return value.
In order for CommandStats to modify a target's score, that target must be tracked prior. This may need to run on a clock in the event new players can join at any time.
Clock commands
The following will need to be run on a clock.
CommandStat trigger applied to all players, who will set their own "ITEMS" score based on commands that they run. This needs to run on a clock because it is being removed during detection.
Detection
The following must be run in numerical order each time you want the player to sell an item. You may need to change target selectors to target a specific player, such as using x/y/z/r parameters depending on your setup.
Cause players to use
/clear
to remove 0 of the specified item. While this does not remove any items, the stored "AffectedItems" trigger will receive the number of items that could have been cleared, which would be equal to the number of emeralds across the player's inventory. Their "ITEMS" score will be set to that number.If a player had at least 16 emeralds ("ITEMS" score of 16+), then remove their "AffectedItems" trigger to preserve their score. If a
/give
or/clear
command is used instead, their "ITEMS" score will be modified and thus can no longer reliably be used.Provide the player with necessary item if they have an "ITEMS" score of 16+, which means they have 16+ emeralds.
Remove the 16 emeralds from the player's inventory.
Summary
You will repeat the "Detection" command set for each item you want to sell. Make sure to change the coordinates for each section.
CommandStats guide.
General info on commands.