Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
1,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Discord = require('discord.js');
  2. var client = new Discord.Client;
  3. var vec3 = require('vec3');
  4. var Block=require("prismarine-block")("1.8");
  5. var mineflayer = require('mineflayer');
  6. var serverHost = 'cafe-mc.com'
  7. var Config = require('./Config.json');
  8. var prefix = Config.prefix;
  9. //var print1 = setInterval(print1, 900);
  10.  
  11. client.on('message', (msg)=> {
  12.     if(!msg.content.startsWith(Config.prefix)) return;
  13.     if(!Config.whitelist.includes(msg.author.id)) return;
  14.     let args = msg.content.slice(prefix.length).trim().split(" ");
  15.     let cmd = args.shift().toLowerCase();
  16.     switch(cmd){
  17.  
  18.         case "chat":
  19.             bot.chat(args.join(" "))
  20.             bot2.chat(args.join(" "))
  21.             bot3.chat(args.join(" "))
  22.         break;
  23.  
  24.     }
  25. })
  26.  
  27. client.login(Config.token)
  28.  
  29.     var bot = mineflayer.createBot({
  30.         host: serverHost,
  31.         port: 25565,
  32.         username: "scottcdowling@yahoo.com",
  33.         password: "lofcannons123",
  34.         version: "1.8.8"
  35.       });
  36.      
  37.       var bot2 = mineflayer.createBot({
  38.           host: serverHost,
  39.           port: 25565,
  40.           username: "codyblackops101@gmail.com",
  41.           password: "Chicago56",
  42.           version: "1.8.8"
  43.         });
  44.  
  45.         var bot3 = mineflayer.createBot({
  46.             host: serverHost,
  47.             port: 25565,
  48.             username: "masterald@mail.ru",
  49.             password: "lofcannons123",
  50.             version: "1.8.8"
  51.           });
  52.  
  53. function getBlocks(botId){
  54.     let allFoundBlocks = [];
  55.     let northBlocks = [];
  56.     let southBlocks = [];
  57.     let eastBlocks = [];
  58.     let westBlocks = [];
  59.         let foundBlocks = botId.findBlock({point: botId.entity.position, matching: Config.searchBlock, maxDistance: 6,})
  60.         if(foundBlocks){
  61.         for (i = 0; i < foundBlocks.length; i++) {
  62.             switch(foundBlocks[i].metadata){
  63.                 case Config.north: northBlocks.push(foundBlocks[i]); break;
  64.                 case Config.south: southBlocks.push(foundBlocks[i]); break;
  65.                 case Config.east: eastBlocks.push(foundBlocks[i]); break;
  66.                 case Config.west: westBlocks.push(foundBlocks[i]); break;
  67.                 case Config.ns:
  68.                     northBlocks.push(foundBlocks[i])
  69.                     southBlocks.push(foundBlocks[i])
  70.                 break;
  71.                 case Config.ew:
  72.                     eastBlocks.push(foundBlocks[i])
  73.                     westBlocks.push(foundBlocks[i])
  74.                 break;
  75.             }
  76.         }
  77.             allFoundBlocks.push(northBlocks, southBlocks, eastBlocks, westBlocks);
  78.             return allFoundBlocks;        
  79.         } else {
  80.             console.log(`[ERROR] No blocks matching the search pattern were found within a 5 block radius!`)
  81.         }
  82. }
  83.  
  84. function printTrue(message){
  85.  
  86.     let stringedMsg = `${message}`
  87.  
  88.     if(stringedMsg.includes("!print")){
  89.         return true;
  90.     } else {
  91.         return false;
  92.     }
  93. }
  94.  
  95. function printStop(message){
  96.  
  97.     let stringedMsg = `${message}`
  98.  
  99.     if(stringedMsg.includes("!stop")){
  100.         return true;
  101.     } else {
  102.         return false;
  103.     }
  104. }
  105.  
  106. function printSand(botID, nB, sB, eB, wB){
  107.     if(nB){
  108.         var vec = new vec3(0, 0, 1)
  109.         let e;
  110.         for (e = 0; e < nB.length; e++){
  111.             botID.placeBlock(nB[e], vec)
  112.         }
  113.     }
  114.     if(sB){
  115.         var vec = new vec3(0, 0, -1)
  116.         let e;
  117.         for (e = 0; e < sB.length; e++){
  118.             botID.placeBlock(sB[e], vec)
  119.         }
  120.     }
  121.     if(eB){
  122.         var vec = new vec3(-1, 0, 0)
  123.         let e;
  124.         for (e = 0; e < eB.length; e++){
  125.             botID.placeBlock(eB[e], vec)
  126.         }
  127.     }
  128.     if(wB){
  129.         var vec = new vec3(1, 0, 0)
  130.         let e;
  131.         for (e = 0; e < wB.length; e++){
  132.             botID.placeBlock(wB[e], vec)
  133.         }
  134.     }
  135. }
  136.  
  137. bot.on('message', function(message) {
  138.  
  139.     let stop = printStop(message)
  140.     let print = printTrue(message)
  141.     if(print){
  142.         let arrayedResults = getBlocks(bot);
  143.         let nBlocks = arrayedResults[0]
  144.         let sBlocks = arrayedResults[1]
  145.         let eBlocks = arrayedResults[2]
  146.         let wBlocks = arrayedResults[3]
  147.        
  148.         myVar = setInterval(printSand, Config.speed, bot, nBlocks, sBlocks, eBlocks, wBlocks)
  149.     }
  150.     if(stop){
  151.         clearInterval(myVar)
  152.     }
  153. });
  154.  
  155. bot2.on('message', function(message) {
  156.  
  157.     let stop = printStop(message)
  158.     let print = printTrue(message)
  159.     if(print){
  160.         let arrayedResults = getBlocks(bot2);
  161.         let nBlocks = arrayedResults[0]
  162.         let sBlocks = arrayedResults[1]
  163.         let eBlocks = arrayedResults[2]
  164.         let wBlocks = arrayedResults[3]
  165.  
  166.         myVar2 = setInterval(printSand, Config.speed, bot2, nBlocks, sBlocks, eBlocks, wBlocks)
  167.     }
  168.     if(stop){
  169.         clearInterval(myVar2)
  170.     }
  171. });
  172.  
  173. bot3.on('message', function(message) {
  174.  
  175.     let stop = printStop(message)
  176.     let print = printTrue(message)
  177.     if(print){
  178.         let arrayedResults = getBlocks(bot3);
  179.         let nBlocks = arrayedResults[0]
  180.         let sBlocks = arrayedResults[1]
  181.         let eBlocks = arrayedResults[2]
  182.         let wBlocks = arrayedResults[3]
  183.  
  184.         myVar3 = setInterval(printSand, Config.speed, bot3, nBlocks, sBlocks, eBlocks, wBlocks)
  185.     }
  186.     if(stop){
  187.         clearInterval(myVar3)
  188.     }
  189. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement