Minecraft – How to send data from one command block to another

minecraft-bedrock-editionminecraft-commands

I am trying to use /testforblock around a player so that whatever block it detects will be put in a certain slot in a certain chest with the use of /replaceitem.

How do I send the block data from /testforblock to /replaceitem?

Best Answer

testforblock <position: x y z > <tileName: Block> [dataValue: int]

testforblock will check for a block and the command execution will succeed if it finds the correct block. otherwise it will fail so you would have to make the second command executing conditional on the first one succeeding.

A method to do this is to make replaceitem a conditional command block. which would only make it execute after testforblock found whatever it is you were checking for.