Skip to content

Instantly share code, notes, and snippets.

@PromoFaux
Last active August 29, 2015 14:16
Show Gist options
  • Save PromoFaux/8891b301e27a170fcf37 to your computer and use it in GitHub Desktop.
Save PromoFaux/8891b301e27a170fcf37 to your computer and use it in GitHub Desktop.
Macro Mod script for minecraft to be used in conjunction with minebot (https://github.com/michaelzangl/minebot). Checks if hotbar contains Picks/shovels/dirt, and if not, refills the hotbar from the inventory. Could be edited to use without minebot.
&pick = "stone_pickaxe";
&shovel = "stone_shovel";
&pillar = "dirt";
IF(automine);
LOG("Automine Disabled");
ECHO("/minebot stop");
UNSET(automine);
ELSE;
LOG("Automine Enabled");
LOG("Enabling minebot");
WAIT(200ms);
ECHO("/minebuild clear")
SET(automine);
DO;
IF((%ITEM% != %&pick%) && (%ITEM% != %&shovel%) && (%ITEM% != %&pillar%));
LOG("Not holding pick/shovel/" %&pillar%);
#c=1;
#pc = 5;
#sc = 2;
FOR(#f,0,6);
&hi = GETSLOTITEM(%#c%);
IF(%#c% < 6);
//LOG(%&hi% at %#c%);
IF(%&hi% != %&pick%);
#pc = #pc - 1;
ENDIF;
ELSE;
//LOG(%&hi% at %#c%);
IF(%&hi% != %&shovel%);
#sc = #sc - 1;
ENDIF;
ENDIF;
#c = #c + 1;
NEXT;
LOG("Number of Picks = " %#pc%);
LOG("Number of Shovels = " %#sc%);
IF((%#pc% = 0) || (%#sc% = 0));
LOG("Need to refill hotbar");
ECHO("/minebot stop");
GUI(inventory);
//WAIT(500ms);
#hs = 36;
FOR(#for,0,6);
WAIT(200ms);
&hi = GETSLOTITEM(%#hs%);
IF(%#hs% < 41);
IF(%&hi% != %&pick%);
GETSLOT(%&pick%,#is,9);
&ii = GETSLOTITEM(%#is%);
IF((%#is% <36)&&(%#is% != -1));
SLOTCLICK(%#is%,2,false);
SLOTCLICK(%#hs%,1,false);
SLOTCLICK(%#is%,1,false);
ELSE;
LOG("No Picks found in inventory, might be time to refill!");
ENDIF;
ENDIF;
ELSE;
IF(%&hi != %&shovel%);
GETSLOT(%&shovel%,#is,9);
&ii = GETSLOTITEM(%#is%);
IF((%#is% <36) && (%#is% != -1));
SLOTCLICK(%#is%,2,false);
SLOTCLICK(%#hs%,1,false);
SLOTCLICK(%#is%,1,false);
ELSE;
LOG("No Shovels Found in inventory, might be time to refill!");
ENDIF;
ENDIF;
ENDIF;
#hs = #hs + 1;
NEXT;
GUI();
//Run a final check on the hotbar, in case there was nothing in the inventory
#c = 1;
#pc = 5;
#sc = 2;
FOR(#f,0,6);
&hi = GETSLOTITEM(%#c%);
IF(%#c% < 6);
IF(%&hi% != %&pick%);
#pc = #pc - 1;
ENDIF;
ELSE;
IF(%&hi% != %&shovel%);
#sc = #sc - 1;
ENDIF;
ENDIF;
#c = #c + 1;
NEXT;
IF((%#pc% = 0) || (%#sc% = 0));
LOG("You have run out of either shovels or picks");
LOG("Stopping operations");
LOG("Maybe one day I will get my own picks");
LOG("If Adam can be bothered");
UNSET(automine);
ELSE;
WAIT(1000ms);
LOG("Starting Minebot");
ECHO("/minebuild clear");
ENDIF;
ELSE;
LOG("No need to refill yet");
ENDIF;
IF(%ITEM% != "dirt");
//KEY(use);
ENDIF;
ENDIF;
WHILE(automine);
ECHO("/minebot stop");
ENDIF;
@PromoFaux
Copy link
Author

As a note, I don't think the scripting language is real Java. But it highlights nicely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment