function fWheat(l: location, d: number, p: number, m: number): loop all blocks in radius ({_p::%{_l}%} + 4) of {_l}: if loop-block is fully grown wheat plant: if {_m::%{_l}%} > 0: set loop-block to wheat plant add 1 to {_d::%{_l}%} add -1 to {_m::%{_l}%} else: set loop-block to air add 1 tp {_d::}