Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. var mineflayer = require('mineflayer');
  2. var navigatePlugin = require('mineflayer-navigate')(mineflayer);
  3. var blockFinderPlugin = require('mineflayer-blockfinder')(mineflayer);
  4. var vec3=require('vec3');
  5.  
  6. var bot = mineflayer.createBot({
  7. host: "", // optional
  8. port: "", // optional
  9. username: "", // email and password are required only for
  10. password: "", // online-mode=true servers
  11. version: '1.8.8'
  12. });
  13.  
  14. navigatePlugin(bot);
  15.  
  16. bot.loadPlugin(blockFinderPlugin);
  17.  
  18.  
  19. bot.on('playerJoined', (player) => {
  20. if(player.username === bot.username){
  21. bot.chat('/server prison')
  22. setTimeout(plot, 1000)
  23. setTimeout(equipAxe, 7000 )
  24. }else{
  25. return;
  26. }
  27. })
  28. function plot(){
  29.  
  30. bot.chat('/p h')
  31. setTimeout(pchat, 1500)
  32. }
  33. function pchat(){
  34. bot.chat('/p chat')
  35. }
  36. function equipAxe () {
  37. bot.equip(279, 'hand', (err) => {
  38. if (err) {
  39. bot.chat(`cant: ${err.message}`)
  40. } else {
  41. find()
  42. }
  43. })
  44. }
  45. function equipSap () {
  46. bot.equip(6, 'hand', (err) => {
  47. if (err) {
  48. bot.chat(`cant: ${err.message}`)
  49. } else {
  50. setTimeout(build, 500)
  51. }
  52. })
  53. }
  54. function build () {
  55. const referenceBlock = bot.blockAt(bot.entity.position.offset(0, 1, -1))
  56. const jumpY = bot.entity.position.y + 0.5
  57. bot.setControlState('jump', true)
  58. bot.on('move', placeIfHighEnough)
  59.  
  60. function placeIfHighEnough () {
  61. if (bot.entity.position.y > jumpY) {
  62. bot.placeBlock(referenceBlock, vec3(0, 1, 0), (err) => {
  63. if (err) {
  64. bot.chat('/msg TheMatrix99 ' + err.message)
  65. return
  66. }
  67. })
  68. setTimeout(equipAxe, 1000)
  69. bot.setControlState('jump', false)
  70. bot.removeListener('move', placeIfHighEnough)
  71. }
  72. }
  73. }
  74. function find(){
  75. var posWood = null;
  76. var posWoodX = null;
  77. var posWoodY = null;
  78. var posWoodZ = null;
  79. bot.findBlock({
  80. point: bot.entity.position,
  81. matching: 17,
  82. maxDistance: 70,
  83. count: 1,
  84. }, function(err, blockPoints) {
  85. if (err) {
  86. bot.chat('Error trying to find: ' + err);
  87. return;
  88. }
  89. if (blockPoints.length) {
  90. posWood = blockPoints[0].position;
  91. posWoodX = blockPoints[0].position.x;
  92. posWoodY = blockPoints[0].position.y -2;
  93. posWoodZ = blockPoints[0].position.z +1;
  94. var temp = vec3(posWoodX, posWoodY, posWoodZ);
  95. console.log(blockPoints[0].position);
  96. bot.navigate.to(temp)
  97. bot.navigate.once('arrived', function () {
  98. if (bot.targetDigBlock) {
  99. bot.chat(`already digging ${bot.targetDigBlock.name}`)
  100. } else {
  101. var target = bot.blockAt(bot.entity.position.offset(0, 2, -1))
  102. if (target && bot.canDigBlock(target)) {
  103. bot.dig(target, t2)
  104. } else {
  105. bot.chat('cannot dig')
  106. }
  107. }
  108. function t2(){
  109. var target = bot.blockAt(bot.entity.position.offset(0, 3, -1))
  110. bot.dig(target, t3)
  111. }
  112. function t3(){
  113. var target = bot.blockAt(bot.entity.position.offset(0, 4, -1))
  114. bot.dig(target, t4)
  115. }
  116. function t4(){
  117. var target = bot.blockAt(bot.entity.position.offset(0, 5, -1))
  118. bot.dig(target, t5)
  119. }
  120. function t5(){
  121. var target = bot.blockAt(bot.entity.position.offset(0, 6, -1))
  122. bot.dig(target, onDiggingCompleted)
  123. }
  124. function onDiggingCompleted (err) {
  125. if (err) {
  126. console.log(err.stack)
  127. return
  128. }
  129. equipSap()
  130. }
  131.  
  132. })
  133. return;
  134. } else {
  135. bot.chat('no more wood rip')
  136. setTimeout(find, 120000)
  137. }
  138. });
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement