[精讚] [會員登入]
178

Mineflayer測試

1.BOT尋路 const mineflayer = require('mineflayer'); co

分享此文連結 //n.sfs.tw/16431

分享連結 Mineflayer測試@大塚 宏 ~認真玩・輕鬆學~
(文章歡迎轉載,務必尊重版權註明連結來源)
最後編修
2024-06-25 10:07:08 By 大塚 宏
 

 1.BOT尋路

const mineflayer = require('mineflayer');
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder');

// 創建一個 Mineflayer 客戶端
const bot = mineflayer.createBot({
  host: 'your.minecraft.server',  // Minecraft 伺服器地址
  username: 'your_bot_username'    // 你的機器人的使用者名稱
});

// 設置機器人使用路徑規劃和移動
bot.loadPlugin(pathfinder);
bot.once('spawn', () => {
  const mcData = require('minecraft-data')(bot.version);
  const movements = new Movements(bot, mcData);
  movements.scafoldingBlocks = []; // 可選:設置機器人建造時使用的方塊

  bot.on('path_update', (r) => {
    if (r.status === 'noPath') {
      bot.chat('無法到達目的地!');
    } else if (r.status === 'complete') {
      bot.chat('已到達目的地!');
    }
  });

  bot.on('chat', (username, message) => {
    if (username === bot.username) return;
    if (message === 'come') {
      const player = bot.players[username];
      if (!player) {
        bot.chat("我找不到你,我不知道要去哪裡。");
        return;
      }
      const pos = player.entity.position.offset(1, 0, 1);
      const goal = new goals.GoalBlock(pos.x, pos.y, pos.z);
      bot.pathfinder.setGoal(goal);
      bot.chat(`我要來了,${username}!`);
    }
  });
});

// 監聽機器人的登入信息
bot.on('login', () => {
  console.log(`機器人 ${bot.username} 登入了!`);
});

 

2.BOT瞬移

const mineflayer = require('mineflayer');

// 創建一個 Mineflayer 客戶端
const bot = mineflayer.createBot({
  host: 'your.minecraft.server',  // Minecraft 伺服器地址
  username: 'your_bot_username'    // 你的機器人的使用者名稱
});

// 監聽機器人的登入信息
bot.on('login', () => {
  console.log(`機器人 ${bot.username} 登入了!`);

  // 瞬間移動到指定座標 (x, y, z)
  teleportTo(100, 70, 200);
});

// 定義瞬間移動函式
function teleportTo(x, y, z) {
  bot.teleport({
    x: x,
    y: y,
    z: z
  }, () => {
    console.log(`已將機器人移動到座標 (${x}, ${y}, ${z})`);
  });
}

END

你可能感興趣的文章

getCoinInfo(API測試) getCoinInfo

[jQuery] 一行搞定if判斷式 一行搞定if判斷式

[實用程式] 假文產生器 遇到一個設計表單的工作,需要一些隨機文字來填充欄位,測試排版是否整齊

動態文字框(TEST) 多邊文字框(TEST)

[JavaScript] subString字串處理(支援中文與全形字符) 一個字串,有可能中英文混和,例如"王小明ab123",這個字串共有8個"字",但是存到資料庫裡面的話,他卻是11個"字元"

Mineflayer測試 1.BOT尋路 const mineflayer = require('mineflayer'); co

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[VB.NET] ComboBox 使用For迴圈移除項目 ComboBox 使用For迴圈移除項目,看起來很簡單,實際上會遇到什麼問題呢

[網賺] 我嘗試過的6種網路賺錢方式 能夠待在家,只透過網路就能賺錢,那該有多好啊

[警告] 虛擬貨幣投資的詐騙手法 最近虛擬貨幣投資非常盛行,畢竟能賺錢的事情,自然會吸引大票投資客入場

[C#] 加密圖片,透過Logistic混沌演算法 加密圖片,透過Logistic混沌演算法

[C#] 字串加密後寫入圖片 字串加密後寫入圖片