So I want to create a shop where you can purchase an Item for a certain amount of items in your inventory.
Example: I have 1 Dirt, with 1 Dirt I can buy 1 wood. I hit the button and 1 Dirt is deleted and 1 Wood is added.
I have looked high and low for an answer and the only thing I find is outdated information, maybe I'm not looking well enough but the only command I've found is “/testfor” but that is no longer a command in java edition.
Can someone please help clarify?
a, etc.) you can check for the existence of an item in the players inventory. By using the 'tag' command you can tag the player to allow you to reference them in other command blocks in the chain. By using the 'clear' command you can remove the item. By using the 'give' command you can give the player the item.
Something like this should work;
It's unlikely to be an issue, but I would also recommend making the last three Command Blocks (the Chain ones) Conditional to prevent the system continuing despite the first command failing (Which is unlikely due to the tag check but it could happen).
I'm not very skilled with command blocks, so perhaps this is a very poor method, but from my testing it works fine!
Good start. Only problem is that in a multiplayer environment this will select the closest player able to trade, and not check if the closest player is able to trade. To fix that, you change the first command like this:
Is there any way using those commands to tests for a named item?
A place for all things about commands and command blocks in vanilla Minecraft; to share, to question, to discuss, and more!Please read the pinned post before posting.