Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mineflayer = require('mineflayer');
- var navigatePlugin = require('mineflayer-navigate')(mineflayer);
- var blockFinderPlugin = require('mineflayer-blockfinder')(mineflayer);
- var vec3=require('vec3');
- var bot = mineflayer.createBot({
- host: "", // optional
- port: "", // optional
- username: "", // email and password are required only for
- password: "", // online-mode=true servers
- version: '1.8.8'
- });
- navigatePlugin(bot);
- bot.loadPlugin(blockFinderPlugin);
- bot.on('playerJoined', (player) => {
- if(player.username === bot.username){
- bot.chat('/server prison')
- setTimeout(plot, 1000)
- setTimeout(equipAxe, 7000 )
- }else{
- return;
- }
- })
- function plot(){
- bot.chat('/p h')
- setTimeout(pchat, 1500)
- }
- function pchat(){
- bot.chat('/p chat')
- }
- function equipAxe () {
- bot.equip(279, 'hand', (err) => {
- if (err) {
- bot.chat(`cant: ${err.message}`)
- } else {
- find()
- }
- })
- }
- function equipSap () {
- bot.equip(6, 'hand', (err) => {
- if (err) {
- bot.chat(`cant: ${err.message}`)
- } else {
- setTimeout(build, 500)
- }
- })
- }
- function build () {
- const referenceBlock = bot.blockAt(bot.entity.position.offset(0, 1, -1))
- const jumpY = bot.entity.position.y + 0.5
- bot.setControlState('jump', true)
- bot.on('move', placeIfHighEnough)
- function placeIfHighEnough () {
- if (bot.entity.position.y > jumpY) {
- bot.placeBlock(referenceBlock, vec3(0, 1, 0), (err) => {
- if (err) {
- bot.chat('/msg TheMatrix99 ' + err.message)
- return
- }
- })
- setTimeout(equipAxe, 1000)
- bot.setControlState('jump', false)
- bot.removeListener('move', placeIfHighEnough)
- }
- }
- }
- function find(){
- var posWood = null;
- var posWoodX = null;
- var posWoodY = null;
- var posWoodZ = null;
- bot.findBlock({
- point: bot.entity.position,
- matching: 17,
- maxDistance: 70,
- count: 1,
- }, function(err, blockPoints) {
- if (err) {
- bot.chat('Error trying to find: ' + err);
- return;
- }
- if (blockPoints.length) {
- posWood = blockPoints[0].position;
- posWoodX = blockPoints[0].position.x;
- posWoodY = blockPoints[0].position.y -2;
- posWoodZ = blockPoints[0].position.z +1;
- var temp = vec3(posWoodX, posWoodY, posWoodZ);
- console.log(blockPoints[0].position);
- bot.navigate.to(temp)
- bot.navigate.once('arrived', function () {
- if (bot.targetDigBlock) {
- bot.chat(`already digging ${bot.targetDigBlock.name}`)
- } else {
- var target = bot.blockAt(bot.entity.position.offset(0, 2, -1))
- if (target && bot.canDigBlock(target)) {
- bot.dig(target, t2)
- } else {
- bot.chat('cannot dig')
- }
- }
- function t2(){
- var target = bot.blockAt(bot.entity.position.offset(0, 3, -1))
- bot.dig(target, t3)
- }
- function t3(){
- var target = bot.blockAt(bot.entity.position.offset(0, 4, -1))
- bot.dig(target, t4)
- }
- function t4(){
- var target = bot.blockAt(bot.entity.position.offset(0, 5, -1))
- bot.dig(target, t5)
- }
- function t5(){
- var target = bot.blockAt(bot.entity.position.offset(0, 6, -1))
- bot.dig(target, onDiggingCompleted)
- }
- function onDiggingCompleted (err) {
- if (err) {
- console.log(err.stack)
- return
- }
- equipSap()
- }
- })
- return;
- } else {
- bot.chat('no more wood rip')
- setTimeout(find, 120000)
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement