Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TanCo Melonator
- log(v1.4);
- //v1.4
- //No longer ever tries to use default orientation values, which was silly
- //v1.3.4
- //Axe durability config now implemented correctly
- //v1.3.3
- //Better suppport for silk touch axes, won't break chests as much
- //Chests now must be placed one block higher
- //Config for durability threshold to switch to next tool, raised default to 12
- //Axes should be consecutive on hotbar, optionally followed by a stick to their right
- //v1.3.2
- //fall protection
- //v1.3.1
- //Hotfix for default row width
- //Announces version on start
- //v1.3
- //Audio alert on emptying into chest
- //Fix for start from any position
- //v1.2
- //New feature: slow mode, more reliable
- //New feature: automatic anti-iebagi east-west drift correction
- //New feature: support for multiple named melon fields eg a field named Thoths
- //Just add more elseif sections for more fields
- //Assumes N/S 2-wide strips of melon stems
- //a 2-block gap between the stems for melons to grow
- //and chests on the north end of the gap
- //Torches placed to keep melons from blocking the north and south ends are recommended
- //Begin user config
- &field = "Thoths"
- #autologout = 1
- //set this to a z position the bot will never encounter
- //ie don't leave at 0 if your field crosses the Minecraft equator
- //strange behavior may result otherwise
- #zcurr = 0
- if(&field = "Thoths");
- #west = -2448
- #north = 12144
- #south = 12353
- else;
- //default field
- #west = -2448
- #north = 12144
- #south = 12353
- endif;
- //0 is fast but has risk of breaking blocks below melons
- //1 is slow but reliable, recommended
- #slowmode = 1
- //0 disables antistuck feature
- //1 attempts to correct positioning errors and logs out on failure
- #antistuck = 1
- //panic if you've been moved out of your row too often, default 5, only works with #antistuck
- #maxiebagis = 5
- //default "diamond_axe" ideally with silk touch, not mandatory
- &tool = "diamond_axe"
- //durability threshold for switching to next axe to prevent breakage, default 12
- #toolduramin = 12
- //end user config
- //don't touch these unless you know what they do
- #forward = 180
- #rowwidth = 1
- #patience = 1
- #wait = 100
- &dest = south
- #thisrow = %XPOS%
- #stuck = 0
- #screwiebagi = 0
- #totaliebagis = 0
- #rownumber = 0
- #ystart = %YPOS%
- #toolslot = 1
- //log(South is %#south%);
- if(@melonator);
- unset(@melonator);
- log(Stopping melonator);
- keyup(forward);
- keyup(sneak);
- keyup(left);
- keyup(right);
- unset(@autochop);
- stop("autochop");
- break;
- else;
- //startup sequence
- //turns off bypass mode on Citadel servers
- echo(/cto);
- //select tool ie diamond_axe
- //do nothing if tool not present
- getslot(%&tool%,#toolslot);
- if((#toolslot < 10) && (#toolslot > -1));
- slot(%#toolslot%);
- log(Selecting %&tool% in slot %#toolslot%);
- else;
- log(Did not find %&tool% on hotbar, this is fine);
- endif;
- //starts an external macro
- //this macro continually attacks if @autochop is set
- //and sleeps if it is not
- //it must be named chop.txt
- exec("chop.txt","autochop");
- set(@melonator);
- log(TanCo melonator enabled);
- if(&field = "Thoths");
- log(Using config for Thoth's dirtfarm);
- else;
- log(WARNING: Using config for default field);
- endif;
- //startup check, where are we in the field?
- log(I am starting from the middle of the field);
- log(Beginning overcomplicated subroutine to find my place);
- #rowcoords = (%#west%+1)
- #rowwidth = 1
- //log(West is %#west% lasttree is %#lasttree%);
- //count down row numbers from the west
- do(99);
- inc(#rownumber);
- inc(#rowcoords,%#rowwidth%);
- if(#rowwidth = 1);
- set(#rowwidth,3);
- else;
- set(#rowwidth,1);
- endif;
- until(#rowcoords > %XPOS%);
- log(I am in row number %#rownumber%);
- loop;
- //brutal test for divisibility by 2
- #evenorodd = (%#rownumber% / 2)
- if((#evenorodd * 2) = %#rownumber%);
- log(This row is even);
- set(#evenrow,1);
- else;
- log(This row is odd);
- set(#evenrow,0);
- endif;
- //knowing the row is odd or even, set row width and facing direction
- if(#evenrow = 1);
- #forward = 180
- &dest = south
- #rowwidth = 1
- else;
- #forward = 0
- &dest = north
- #rowwidth = 3
- endif;
- //begin main loop
- do();
- //Always sneak, and walk
- keydown(forward);
- keydown(sneak);
- //when slowmode is not set then constantly swing stick
- //some risk of breaking blocks below melons unless using slowmode
- //if iebagi or another outside force bumps the bot, do not swing until position restored
- if(!#screwiebagi);
- if(!#slowmode);
- set(@autochop);
- else;
- //count to #patience if z position does not change while in main loop
- if(%ZPOS% = #zcurr);
- inc(#stuck);
- else;
- #stuck = 0
- endif;
- #zcurr = %ZPOS%
- //if z position is not changing then break melon
- if(#stuck >= #patience);
- set(@autochop);
- else;
- unset(@autochop);
- endif;
- //end position-based melon detection
- endif;
- else;
- unset(@autochop);
- endif;
- //Terminal sequence for west end of the field
- if(%XPOS% <= #west);
- log(Reached west end of the field, stopping);
- unset(@melonator);
- keyup(forward);
- keyup(sneak);
- keyup(left);
- keyup(right);
- unset(@autochop);
- stop("autochop");
- if((#autologout = 1) && (!@melonator));
- log(logging out in 5 seconds);
- wait(5);
- disconnect;
- endif;
- stop;
- endif;
- //sequence for unexpected east-west drift
- //and by unexpected, I mean iebagi teleporting to you
- //and bumping your bot so it breaks stems instead of melons
- //will wait about 1.5 seconds after a bump before swinging again
- if(#antistuck = 1);
- if(%XPOS% > #thisrow);
- log(iebagi detected);
- set(#screwiebagi,10);
- inc(#totaliebagis);
- if(&dest = "south");
- keyup(left);
- keydown(right);
- wait(300ms);
- elseif(&dest = "north");
- keyup(right);
- keydown(left);
- wait(300ms);
- endif;
- elseif(%XPOS% < #thisrow);
- log(iebagi detected);
- set(#screwiebagi,10);
- inc(#totaliebagis);
- if(&dest = "south");
- keyup(right);
- keydown(left);
- wait(300ms);
- elseif(&dest = "north");
- keyup(left);
- keydown(right);
- wait(300ms);
- endif;
- else;
- keyup(left);
- keyup(right);
- if(#screwiebagi >= 0);
- dec(#screwiebagi);
- endif;
- endif;
- //log(Screwiebeagi is %#screwiebagi%);
- //sequence for being stuck on the edge of a melon
- //count for #stuck is controlled by the anti-iebagi sequence
- if(#stuck > 30);
- log(help help I'm stuck);
- keydown(left);
- wait(300ms);
- keyup(left);
- keydown(right);
- wait(600ms);
- keyup(right);
- keydown(left);
- wait(300ms);
- endif;
- if((#stuck >= 100) || (#totaliebagis > #maxiebagis));
- log(ERROR: All attempts to unstick myself have failed);
- log(%#stuck%% stuck, %#totaliebagis% iebagis detected);
- log(Disconnecting in 5);
- unset(@melonator);
- log(Stopping melonator);
- keyup(forward);
- keyup(sneak);
- keyup(left);
- keyup(right);
- unset(@autochop);
- stop("autochop");
- if(!@melonator);
- wait(5);
- disconnect;
- endif;
- endif;
- //close antistuck sequence
- endif;
- //Detect near north end of field facing north, look at feet
- //Makes it less likely to break melon chests by accident
- if((%ZPOS% = (#north + 1)) && (&dest = "north"));
- //log(Getting close. Looking at feet.);
- look(%#forward%,65);
- else;
- look(%#forward%,26);
- endif;
- //Detect arrival at north end of field
- if((%ZPOS% = #north) && (&dest = "north"));
- unset(@autochop);
- log(reached north end of field);
- if(#antistuck = 1);
- log(I have experienced %#totaliebagis% iebagis this row);
- endif;
- unset(#totaliebagis);
- //chest melons
- playsound(entity.enderdragon.death);
- keyup(sneak);
- wait(%#wait%ms);
- look(0,340);
- wait(%#wait%ms);
- key(use);
- wait(%#wait%ms);
- log(Chesting crops);
- for(#forthrow,54,80);
- slotclick(%#forthrow%,l,true);
- wait(%#wait%ms);
- next;
- gui();
- keydown(sneak);
- //end chesting sequence
- //slide to the west
- #current = %XPOS%
- look(270,0);
- keydown(forward);
- //keydown(sneak);
- //log(row width %#rowwidth%);
- do();
- //log(made it to do in north check);
- wait(100ms);
- until(%XPOS% = (#current-#rowwidth));
- //wait(1);
- log(reached next row);
- #thisrow = %XPOS%
- &dest = south
- #forward = 180
- if(!#slowmode);
- set(@autochop);
- endif;
- //Alternates row width
- if(#rowwidth = 1);
- #rowwidth = 3
- else;
- #rowwidth = 1
- endif;
- //log(row width %#rowwidth%);
- endif;
- //same but for south end of field
- //no chests here
- if((%ZPOS% = #south) && (&dest = "south"));
- unset(@autochop);
- log(reached south end of field);
- if(#antistuck = 1);
- log(I have experienced %#totaliebagis% iebagis this row);
- endif;
- unset(#totaliebagis);
- //slide to the west
- #current = %XPOS%
- look(270,0);
- keydown(forward);
- keydown(sneak);
- //log(row width %#rowwidth%);
- do();
- //log(made it to do in south check);
- wait(100ms);
- until(%XPOS% = (#current-#rowwidth));
- //wait(1);
- log(reached next row);
- #thisrow = %XPOS%
- &dest = north
- #forward = 0
- if(!#slowmode);
- set(@autochop);
- endif;
- //Alternates row width
- if(#rowwidth = 1);
- #rowwidth = 3
- else;
- #rowwidth = 1
- endif;
- endif;
- //check hunger, deactivate axe, eat food if needed, reactivate axe
- if(%HUNGER% <= 18);
- look(0,270);
- unset(@autochop);
- keyup(forward);
- keyup(back);
- keyup(left);
- keyup(right);
- log(Getting hungry. Eating from offhand.);
- //slot(%#toolslot%);
- do();
- key(use);
- until(%HUNGER% > 19);
- if(!#slowmode);
- set(@autochop);
- endif;
- endif;
- //fall protection
- if(%YPOS% < (#ystart - 1));
- log(Help help, I've fallen and I can't get up.);
- unset(@autochop);
- unset(@melonator);
- disconnect;
- endif;
- //Switch to new tool if current tool is about to break
- //Always switches to the right
- if((%DURABILITY% < #toolduramin) && (%DURABILITY% > 1));
- log(&4Durability low! %DURABILITY%);
- inventoryup(1);
- endif;
- //delay for main loop
- //100ms is good enough
- wait(%#wait%ms);
- //log(made it to end of main loop);
- while(@melonator);
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement