Minecraft: How To Make A Shop In Minecraft With Command Blocks And Functions

So I want to create a shop where you can purchase an Item for a certain amount of items in your inventory.

Đang xem: How to make a shop in minecraft with command blocks

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.

Read more: How To Build Roof In Minecraft Roof Designs, Tutorials/Roof Types

Something like this should work;

p}> add itemExchangeThen chain that command block into another one that does

p remove itemExchangeThen you're done

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:

execute as
sI Have Copper Ore, How To Make Copper Bars Wow, Making Copper Bars

p}> add itemExchange

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.

Leave a Comment