How to not allow people to take items out of chest (Bedrock)

I want to have a chest where other players are able to look at the contents of a chest but I don't want them to be able to take the items out. Is this possible to do with command blocks? I am playing the newest version of Minecraft Bedrock Edition on xbox.


Solution 1:

First

This assumes you know how chain command blocks and basic commands work.

How

Have a repeating command block always active set to clear an item. Example with bedrock block:

/clear @a[r=20] bedrock 

Now set the block with the chest to air. Have a chain conditional always active command block. Lets pretend my chest is at 0, 0, 0:

/setblock 0 0 0 air

Have a chain conditional always active command block. Now have the original chest somewhere. Lets say my template chest is at 5, 5, 5:

/clone 5 5 5 5 5 5 0 0 0

We put the template chest where our old chest was.

More

Put more chain conditional always active command blocks to have buttons that do something when you click them!