Agent Farm
Agent Plants a Farm @showdialog
Your Agent farm hand will plant a field of crops for you!

On chat command
Change the ||player:on chat command|| block on the workspace from "run" to "farm".
player.onChat("farm", function () {
})
Teleport your Agent
Grab and drag out the ||agent:agent teleport to player|| block and drop it into the ||player:on chat command|| block.
player.onChat("farm", function () {
agent.teleportToPlayer()
})
Set your Agent’s inventory
Get the ||agent:agent set block or item|| block from the Toolbox and drop it under the ||agent:agent teleport|| block. Set the count to 16.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(GRASS, 16, 1)
})
Give your Agent seeds
Go back to the Toolbox, grab the ||blocks:item|| block, and drop it into the ||agent:agent set block or item|| block replacing the grass block. Click on the ||blocks:item|| block selection and change it to seeds.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
})
Allow Agent to destroy obstacles
Get an ||agent:agent place on move|| block and drop it after the ||agent:agent set block or item|| block. In this block, click on ||agent:place on move|| and change to ||agent:destroy obstacles||. Then change the OFF setting to ON.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
})
Add a loop to plant 4 times in one row
In the Toolbox, find the ||loops:repeat|| block and drop it in after the ||agent:agent destroy obstacles|| block.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
}
})
Move the Agent
Drag out an ||agent:agent move|| block and drop it into the ||loops:repeat|| block. Change the direction from ||agent:forward| to ||agent:left|.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
agent.move(LEFT, 1)
}
})
Instruct Agent to till the ground
Look for the ||agent:agent till|| block in the Toolbox. Grab it and drop it after the ||agent:agent move|| block in the repeat loop.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
agent.move(LEFT, 1)
agent.till(FORWARD)
}
})
Instruct Agent to plant seeds
Drag out the ||agent:agent place|| block and drop it after the ||agent:agent till|| block.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
agent.move(LEFT, 1)
agent.till(FORWARD)
agent.place(FORWARD)
}
})
Add an outer loop to move to the next rows
Grab another ||loops:repeat|| block and drop it so it surrounds the first ||loops:repeat|| block.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
for (let index = 0; index < 4; index++) {
agent.move(LEFT, 1)
agent.till(FORWARD)
agent.place(FORWARD)
}
}
})
Move the Agent back
Drag an ||agent:agent move|| block and drop it after the inner ||loops:repeat|| loop, but inside the outer ||loops:repeat|| block that you just placed. Change the direction from ||agent:forward| to ||agent:back||.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
for (let index = 0; index < 4; index++) {
agent.move(LEFT, 1)
agent.till(FORWARD)
agent.place(FORWARD)
}
agent.move(BACK, 1)
}
})
Move Agent to beginning of row
Drag another ||agent:agent move|| block and drop it after the ||agent:agent move back|| block. Change the direction from ||agent:forward| to ||agent:right|. Change the number from 1 to 4.
player.onChat("farm", function () {
agent.teleportToPlayer()
agent.setItem(SEEDS, 16, 1)
agent.setAssist(DESTROY_OBSTACLES, true)
for (let index = 0; index < 4; index++) {
for (let index = 0; index < 4; index++) {
agent.move(LEFT, 1)
agent.till(FORWARD)
agent.place(FORWARD)
}
agent.move(BACK, 1)
agent.move(RIGHT, 4)
}
})
Run your code!
Click on the green Play button to run your code in Minecraft. Move to a flat area and press T to open the chat window. Then type "farm" to run your code.