Ok, after some (5-10hrs) work I got a solution:
Now, what the numbered parts are:
- Button switch - one button press is like a lever switch
- Fast Redstone clock (minimal repeater delay)
- Piston that turns the system on; the repeater is essential, otherwise the piston will go on-off-on on button press
- Command blocks, each part has these four commands:
/execute @a[ry=112,rym=-112] ~ ~ ~ fill ~ ~ ~+1 ~ ~+1 ~+1 minecraft:barrier 0 replace minecraft:air
/execute @a[ry=22,rym=157] ~ ~ ~ fill ~+1 ~ ~ ~+1 ~+1 ~ minecraft:barrier 0 replace minecraft:air
/execute @a[ry=-67,rym=68] ~ ~ ~ fill ~ ~ ~-1 ~ ~+1 ~-1 minecraft:barrier 0 replace minecraft:air
/execute @a[ry=-158,rym=-22] ~ ~ ~ fill ~-1 ~ ~ ~-1 ~+1 ~ minecraft:barrier 0 replace minecraft:air
- Finally, this last Command Block resets the whole cycle:
/execute @a ~ ~ ~ fill ~-5 ~-2 ~-5 ~+5 ~+2 ~+5 minecraft:air 0 replace minecraft:barrier 0
- all repeaters must be set to minimum delay
- the lower #4 command blocks are not connected with a repeater, the upper ones are.
- all the Pistons are Sticky Pistons
- the system will not delete the remaining Barrier blocks when turned off; It's better to use this:
- I recommend to use "minecraft:stained_glass 4" instead of "minecraft:barrier 0", if the player breaks it, a new glass block appears almost instantly.
- It's convertable to use the 1.9 chain command block feature, but I don't recommend it because of different repeat frequency.
- The system is reliable - you can't move forwards whatever you try.
- Even if you are falling/flying upwards/sprinting/potion sped up, the barrier block(s) farther from you will be deleted.
- You can try it yourself and use/test/edit it! - let's say, it could look like this:
The Command block next to the Button has this inside:
/clone XYZLeftChest XYZLeftChest XYZWool
The other two new Command blocks reset the cycle:
/setblock XYZChestUnderHopper minecraft:chest
/setblock XYZWool minecraft:air
Inside the left Chest place some items for signal length.