I was wondering if command blocks could take away player items. For instance, 5 rotten flesh for 1 paper. I know how command blocks give items, but can they take items away? (Working on map, need answers.)
using the clear command, / is not needed with the command block, you can remove all of the items of a certain id from a players inventory. ex: "clear @a 137" would clear command blocks from all players
Rollback Post to RevisionRollBack
Your brain is so powerful, it would take a state of the art computer the size of a factory to come even close to matching the processing power.
Yes they can, you can check out sethbling's redstone challenge map if you want. He has command blocks that take away all items between different rooms!
They can take items, but they will not search for it in your inventory.
This means, that even if you use them like "take one grass, give one gunpowder" they will give you gunpowder even if you don't have grass in inventory.
If you want to make shop, you should use villagers.
why I don't thank you can with command blocks take a look at this It's way to have villagers buy and sell anything you want them to you also need NBTExplorer
Custom villagers would be the easiest way to go about this, but if you really want, you could use command blocks to teleport the player to a place, kill him, check his items for grass (easily done with item stacking and water currents) and yeah. Something like that? O_O
They can take items, but they will not search for it in your inventory.
This means, that even if you use them like "take one grass, give one gunpowder" they will give you gunpowder even if you don't have grass in inventory.
If you want to make shop, you should use villagers.
not necessarily. using a comparator, have the grass clearer in front, then place a comparator next to it facing away, then link the compa. to the gunpowder giver. it will only give gunpowder if it is able to clear grass. villagers would be easier.
Rollback Post to RevisionRollBack
Feel free to pm me about any concerns,corrections,or questions.
I do redstone, pvp, light map making, enjoy sweet tea, and I'm a Leo.
If I helped, Up-vote my post please. Quote me if you require my attention.
use the command in a command block for example, /clear @p 137
this command would remove all command blocks from the nearest player's inventory assuming they have any in it. If you want to give a player something, use /give @p (item id)
This would give the closest player the item that corresponds to the ID. However for something like orange wool, you would have to give the item ID then the data value. Using an Enchanted Golden Apple as an example, /give @p 322:1
Using this command would then the give the nearest player an Enchanted Golden apple.
If you have any trouble finding the ID of something, follow this link, http://minecraft-ids.grahamedgecombe.com/ This is the Minecraft ID list. It has the ID for everything in Minecraft including all the weird items like fire, air, water source block, lava source block, etc. If you found this information helpful, please pm me.
For 1.8, /clear (playername) minecraft:rotten_flesh 0 5 the zero is needed without it the game looks for a rotten flesh with a modifier of 5 for example lime wool to the game is wool 5 in this command the five indicates the amount to take away.
/clear PlayerUsername ItemID Amount
and another command block
/give PlayerUsername ItemID Amount
This means, that even if you use them like "take one grass, give one gunpowder" they will give you gunpowder even if you don't have grass in inventory.
If you want to make shop, you should use villagers.
The one problem with this is that it broadcasts a message to the whole world.
I tested it on my server, but no broadcast was messaged.
not necessarily. using a comparator, have the grass clearer in front, then place a comparator next to it facing away, then link the compa. to the gunpowder giver. it will only give gunpowder if it is able to clear grass. villagers would be easier.
I do redstone, pvp, light map making, enjoy sweet tea, and I'm a Leo.
If I helped, Up-vote my post please.
Quote me if you require my attention.
this command would remove all command blocks from the nearest player's inventory assuming they have any in it. If you want to give a player something, use /give @p (item id)
This would give the closest player the item that corresponds to the ID. However for something like orange wool, you would have to give the item ID then the data value. Using an Enchanted Golden Apple as an example, /give @p 322:1
Using this command would then the give the nearest player an Enchanted Golden apple.
If you have any trouble finding the ID of something, follow this link, http://minecraft-ids.grahamedgecombe.com/ This is the Minecraft ID list. It has the ID for everything in Minecraft including all the weird items like fire, air, water source block, lava source block, etc. If you found this information helpful, please pm me.
What you do is this to clear ALL items: clear @p
You could use this setup:
First make a clock with this command in the command block:
This will test for a player in a 10 block radius of the command block with 5 rotten flesh. These variables can obviously be changed around.
Then hook a comparator up to the other side of the command block, and then a repeater, and then a command block with this command in it:
Then you can have a repeater and command block with whatever command you want in it. If you wanted to give the player 1 paper do this:
Hope this helped!
New maps in progress.....
For 1.8, /clear (playername) minecraft:rotten_flesh 0 5 the zero is needed without it the game looks for a rotten flesh with a modifier of 5 for example lime wool to the game is wool 5 in this command the five indicates the amount to take away.
LTLGamer
Minecrafter and Everyday Youtuber