1

I had the idea of creating a command block to make easy changes to the floor of a house. In order to make it user friendly to others, I wanted to have the command block do a fill command based on a block that was placed on top of it.

I understand that there are limitations to retrieving a blocks data on Bedrock Edition and there are only 2 workarounds I can think of:

  1. Have 1 command block for each type of block there is in Minecraft for the player to choose from.

    • I'd rather not do this due to amount of block choices there are.
  2. Have a set of command blocks run clone commands to copy the user-selected block to each tile of the floor.

    • I'd rather not do this either since the floor has over 1600 blocks and i don't feel like writing that many lines of code on my Switch :P

My question is: Is there a simple way to do this without using a massive amount of code or command blocks?

2 Answers 2

1

I don't know MCBE commands well, but here is at least an idea:

First, clone the block to the lowest X, Y and Z coordinate of your area. Then, clone the block from there one block further in the positive X direction. Then clone both blocks together, this time two blocks further in X direction. Then four, eight and so on. Then repeat for the Y and Z directions.

I assume the commands would look something like this:

/clone ~ ~-1 ~ ~ ~-1 ~ 0 0 0
/clone 0 0 0 0 0 0 1 0 0
/clone 0 0 0 1 0 0 2 0 0
/clone 0 0 0 3 0 0 4 0 0
/clone 0 0 0 7 0 0 8 0 0
/clone 0 0 0 15 0 0 0 1 0
/clone 0 0 0 15 1 0 0 2 0
/clone 0 0 0 15 3 0 0 4 0
/clone 0 0 0 15 7 0 0 0 1
/clone 0 0 0 15 7 1 0 0 2

With this method you only need n+1 commands to fill an area of 2^n blocks with an arbitrary block type. So for example just 3×5+1=16 commands for the 32768 blocks in a (2^5)³=32×32×32 area.

2
  • I'm having one of those "why didn't I think of that." moments. Thanks for the insight! Apr 15, 2020 at 11:49
  • The idea comes from binary search (at least for me). If you haven't studied algorithms, it's harder to get the idea. Apr 15, 2020 at 14:43
0

It isnt possible to do that with detecting blocks currently, but you can use the >fill replace< parameter like this:

/fill [your base start] [your base end] [new block] 0 replace [old block]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .