I'm having the infuriatingly difficult task of setting up an item shop in with command blocks. I've designed and perfected a fine Experience shop, which is well and all, but what i REALLY want is a way to buy items, WITH items.
I've tried several methods; /clear, with the right player conditions, /give, with the right conditions, and so on.
Unfortunately, they're both flawed:
1) unless the targeted player has NO OTHER items in their inventory except for the "buying" item , /clear can be cheated past, or not work at all.
2) There's the chance that /clear will wipe the entire inventory
3)For the /give, i stumbled upon a brilliant idea "I'll try /give -item-id"!!!!!!!!!! And then it turns out that you "/give" negative items, and thus subtract currency (gold, diamonds, whatever) from a player's inventory.
So, I'm wondering if anyone else out there has discovered or is working on a solution to this problem. I would love any feed back anyone has to offer.
The function that you want is possible by using "/clear playername itemid itemcount" where the playername can of course be exchanged by tags like @p[lm=12,l=13,r=10] and stuff like that.
The only problem is that you get no detectable output from the clear command, you have no way to detect if the player has the item in his inventory only to take it if he/she has. At least not with that one single command.
What you simply can do is create custom villager shops where you can trade as example wool as tokens for on enchanted diamond sword.
Thanks a TON. I've never heard of the the further sub-commands for /clear before. This changes things. However, as you noted, there is no viable way (yet) to confirm that the player holds [target] item.
But, this is a big step for me.
I have also checked out Villager shops, but I want a more automated, one-click-shop feel. If there's no other choice, I will probably use them.
The only way is using buildcraft. Put items in, obsidian pipe pick is up, diamond pipe filters, if it's wrong give it back, if it's right send it to a pressure plate that activates the command block.
Actually, I've heard rumors of the Allocator, or some sort of similar block, being implemented in 1.5.
Thanks a TON. I've never heard of the the further sub-commands for /clear before. This changes things. However, as you noted, there is no viable way (yet) to confirm that the player holds [target] item.
But, this is a big step for me.
I have also checked out Villager shops, but I want a more automated, one-click-shop feel. If there's no other choice, I will probably use them.
Actually, I've heard rumors of the Allocator, or some sort of similar block, being implemented in 1.5.
As a notice, the /clear command does NOT clear a specific amount. /clear will always clear EVERY item it finds. The correct /clear command with parameters is:
/clear [player] [item ID] [damage value]
Damage values can be found on certain items such as wool, to target different colors. Item ID 373 would target every single potion in the game; adding damage values afterwards would allow you to select specific potions. But in short, there's no way to clear a specified amount of items.
As a notice, the /clear command does NOT clear a specific amount. /clear will always clear EVERY item it finds. The correct /clear command with parameters is:
/clear [player] [item ID] [damage value]
Damage values can be found on certain items such as wool, to target different colors. Item ID 373 would target every single potion in the game; adding damage values afterwards would allow you to select specific potions. But in short, there's no way to clear a specified amount of items.
Thanks. However, on the topic of Potion Damage Values, do you know how to /give certain potions? Looking up any "item ID" list online, they all gave the same ID's. However, whenever i tried using one, the console would give a "item value is invalid"
This was before 1.4.5, so it might have been a bug.
But i think it might be something else, because i've noticed that anything with secondary values (373:xxxx) like potions, don't work. Do you know anything on that?
Thanks. However, on the topic of Potion Damage Values, do you know how to /give certain potions? Looking up any "item ID" list online, they all gave the same ID's. However, whenever i tried using one, the console would give a "item value is invalid"
This was before 1.4.5, so it might have been a bug.
But i think it might be something else, because i've noticed that anything with secondary values (373:xxxx) like potions, don't work. Do you know anything on that?
I've tried several methods; /clear, with the right player conditions, /give, with the right conditions, and so on.
Unfortunately, they're both flawed:
1) unless the targeted player has NO OTHER items in their inventory except for the "buying" item , /clear can be cheated past, or not work at all.
2) There's the chance that /clear will wipe the entire inventory
3)For the /give, i stumbled upon a brilliant idea "I'll try /give -item-id"!!!!!!!!!! And then it turns out that you "/give" negative items, and thus subtract currency (gold, diamonds, whatever) from a player's inventory.
So, I'm wondering if anyone else out there has discovered or is working on a solution to this problem. I would love any feed back anyone has to offer.
And sorry if the above is hard to understand.
Thanks a TON. I've never heard of the the further sub-commands for /clear before. This changes things. However, as you noted, there is no viable way (yet) to confirm that the player holds [target] item.
But, this is a big step for me.
I have also checked out Villager shops, but I want a more automated, one-click-shop feel. If there's no other choice, I will probably use them.
Actually, I've heard rumors of the Allocator, or some sort of similar block, being implemented in 1.5.
As a notice, the /clear command does NOT clear a specific amount. /clear will always clear EVERY item it finds. The correct /clear command with parameters is:
Damage values can be found on certain items such as wool, to target different colors. Item ID 373 would target every single potion in the game; adding damage values afterwards would allow you to select specific potions. But in short, there's no way to clear a specified amount of items.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Thanks. However, on the topic of Potion Damage Values, do you know how to /give certain potions? Looking up any "item ID" list online, they all gave the same ID's. However, whenever i tried using one, the console would give a "item value is invalid"
This was before 1.4.5, so it might have been a bug.
But i think it might be something else, because i've noticed that anything with secondary values (373:xxxx) like potions, don't work. Do you know anything on that?
You can find a full list of potion damage values here: http://www.minecraftwiki.net/wiki/Potions (listed in the tables as "DV").
For the give command, the parameters are in the following order:
So the damage value is at the end, rather than after the item ID. So for giving a potion of regeneration, you would put:
Hope this helps!
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/