Advertisement
Guest User

Untitled

a guest
May 8th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. // OSX:
  2. // - have nodejs (default works on OSX)
  3. // - npm install mineflayer
  4. // - edit this script, set server, change port if not default
  5. // - username/pass are minecraft login email address + password
  6. //
  7. // set moveinterval to number of seconds between movements. This is also movement duration.
  8. //
  9. // - Log in using normal client, empty inventory (optional), put food in first inventory slot
  10. // - Go to a safe area (inside, well lighted)
  11. // - Log out of normal minecraft
  12. // - Start this script and wait (preferably use normal IP, running remove often doesn't work):
  13. // node minecraft_idlebot.js
  14.  
  15.  
  16. var mineflayer = require('mineflayer');
  17. var bot = mineflayer.createBot({
  18. host: "libercraft.net", // optional
  19. port: 25565, // optional
  20. username: "whatever@whatever.org",
  21. password: "1l0v3my1r0nf@rm",
  22. });
  23.  
  24. var moveinterval = 2; // 2 second movement interval
  25. var lasttime = -1;
  26. var moving = 0;
  27. var actions = [ 'forward', 'back', 'left', 'right', 'jump']
  28. var lastaction;
  29.  
  30. bot.on('chat', function(username, message) {
  31. if (username === bot.username) return;
  32. console.log(message);
  33. });
  34.  
  35. bot.on('health',function() {
  36. if(bot.food < 15) {
  37. bot.activateItem();
  38. console.log("Ate something");
  39. }
  40. });
  41.  
  42. bot.on('time', function() {
  43. if (lasttime<0) {
  44. lasttime = bot.time.age;
  45. console.log("Age set to " + lasttime)
  46. } else {
  47. var interval = moveinterval*20;
  48. if (bot.time.age - lasttime > interval) {
  49. if (moving == 1) {
  50. bot.setControlState(lastaction,false);
  51. moving = 0;
  52. console.log("Stopped moving");
  53. lasttime = bot.time.age;
  54. } else {
  55. lastaction = actions[Math.floor(Math.random() * actions.length)];
  56. bot.setControlState(lastaction,true);
  57. moving = 1;
  58. console.log("Started moving " + lastaction);
  59. lasttime = bot.time.age;
  60. }
  61. }
  62. }
  63. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement