// Configure #north and #south to the very edge of the field.
// Leave 1 block in each direction on level with the field, so you don't fall off.
// Start at the North-East end of the field. The bot will pick in rows from north to south, then slide west for the next row.
// #toolslot is the slot used to break the crops. Put a fortune 3 tool in the slot to get more carrots or potatoes.
// &plant is the item used to replant (e.g. "wheat_seeds","carrot","potato")
// &mode changes the bot's behavior. "default" will harvest a row, then replant it, and repeat. "plant" will plant without harvesting
// and "harvest" will harvest without planting.
// Config
#north = -2626
#south = -2447
#toolslot = 8
&plant = "wheat_seeds"
&mode = "default"
#wait = 100
// End Config
If(wheat1);
Log(wheat1 Disabled);
unset(wheat1);
stop;
Else;
log("wheat1 Enabled");
set(wheat1);
slot(1);
do;
if(%ZPOS% = %#south%);
#dest = %#north%
// Throw wheat & seeds
look(180,-40);
gui(inventory);
wait(500ms);
for(#forthrow,9,26);
slotclick(%#forthrow%);
wait(%#wait%ms);
slotclick(-999);
wait(%#wait%ms);
next;
gui();
look(90,90);
else;
#dest = %#south%
look(270,90);
endif;
do;
keydown(left);
do;
// Mode
if(%&mode% = "plant")
set(plant);
elseif(%&mode% = "harvest")
unset(plant);
elseif(%&mode% = "default")
if(%#dest% = %#south%);
look(270,90);
unset(plant);
else;
look(90,90);
set(plant);
endif;
endif;
// If planting
if(plant);
if(%&plant% = "wheat_seeds");
// If item is seeds and stack size >5
if((%ITEM% = %&plant%) && (%STACKSIZE% > 5))
key(use);
else;
keyup(left);
do;
// If no stacks on hotbar >5
if(%INVSLOT% = 9);
// Get more seeds
gui(inventory);
wait(500ms);
for(#cfor,9,35);
getslot(%&plant%,#cslot,%#cfor%);
if(%#cslot% < 36)
slotclick(%#cslot%,1,true);
endif;
wait(%#wait%ms);
next;
gui();
wait(500ms);
slot(1);
else;
inventoryup(1);
endif;
until((%ITEM% = %&plant%) && (%STACKSIZE% > 5))
keydown(left);
endif;
else;
pick("%&plant%");
key(use);
endif;
// else pick
else;
slot(%#toolslot%);
key(attack);
endif;
#cz = %ZPOS%
while(%ZPOS% != %#cz%);
until(%ZPOS% = %#dest%);
keyup(left);
keyup(right);
#cx = %XPOS%
if((%#dest% = %#north%) || (plant) || (%&mode% = "harvest"));
do;
look(90,90);
keydown(sneak);
keydown(back);
until(%#cx% != %XPOS%);
endif;
keyup(sneak);
keyup(back);
keyup(forward);
loop;