Obsidian block command? [closed]

Solution 1:

This answer is for the java version, a recent edit added the information that it is about the bedrock edition

Stand where you want to place a tower of command blocks and run these commands one after the other without moving away from where you are standing until you executed all 7 commands, this will slowly build a tower of command blocks one block north of your position:

/scoreboard objectives add hitByObsidian dummy
/setblock ~ ~ ~-1 minecraft:repeating_command_block[conditional=false,facing=up]{Command:"/execute as @e[tag=Spread] run data modify entity @s Pos[0] set from entity @e[limit=1,sort=random] Pos[0]"}
/setblock ~ ~1 ~-1 minecraft:chain_command_block[conditional=false,facing=up]{auto:1b,Command:"/execute as @e[tag=Spread] run data modify entity @s Pos[1] set from entity @e[limit=1,sort=random] Pos[1]"}
/setblock ~ ~2 ~-1 minecraft:chain_command_block[conditional=false,facing=up]{auto:1b,Command:"/execute as @e[tag=Spread] run data modify entity @s Pos[2] set from entity @e[limit=1,sort=random] Pos[2]"}
/setblock ~ ~3 ~-1 minecraft:chain_command_block[conditional=false,facing=up]{auto:1b,Command:"execute as @e at @s store success score @s hitByObsidian run fill ~-1 ~-1 ~-1 ~1 ~1 ~1 air replace minecraft:obsidian"}
/setblock ~ ~4 ~-1 minecraft:chain_command_block[conditional=false,facing=up]{auto:1b,Command:"kill @e[scores={hitByObsidian=1},tag=!Spread]"}
/setblock ~ ~5 ~-1 minecraft:chain_command_block[conditional=false,facing=up]{auto:1b,Command:"execute at @e[tag=Spread,scores={hitByObsidian=1}] run fill ~-1 ~-1 ~-1 ~1 ~1 ~1 minecraft:obsidian replace air"}

The first command creates a scoreboard objective and the other 6 create a command block each.

The first command block will teleport every entity with the tag Spread to the same x position as a random entity
The second command block will teleport every entity with the tag Spread to the same y position as a random entity
The third command block will teleport every entity with the tag Spread to the same z position as a random entity

The fourth command block will remove all obsidian that is close to any entity and store a scoreboard value for any entity that removed obsidian (This is used to detect what entities should be killed. It also makes it possible to remove some of the infection by throwing things at it)

The fifth command block kills every entity that removed obsidian due to the fourth command block, unless they have a Spread-tag

The sixth command block places obsidian close to any entity with a Spread-tag that removed obsidian due to the fourth command block

This is mostly chance based, so it will make the obsidian spread slowly, you can speed it up by using more entities with Spread-tags.
I recommend you to use this command to spawn small, invulnerable, and invisible armor stands with a Spread-tag:

/summon minecraft:armor_stand ~ ~ ~ {NoGravity: 1b,Invulnerable: 1b, Tags: ["Spread"],Small: 1b}

Note: Once you are done with all this you need to either power the blue command block with a lever, or set it to "always active"

Note 2: Adding a Spread-tag to a player should result in interesting behaviour if that player walks close to obsidian. The player will not get teleported randomly and the obsidian won´t kill the player, though the player will likely suffocate anyway. I have not tested this yet.