-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.ts
142 lines (129 loc) · 4.81 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import TaskManager from "./task/TaskManager";
const mineflayer = require("mineflayer");
import Miner from "./bot/Miner";
import BotManager from "./bot/BotManager";
// const bot = mineflayer.createBot({
// username: "ender_bot",
// host: "www.bierdl.cn",
// })
//
// let spamLock = 1
//
// let checkPoint = false
import {goals, pathfinder} from "mineflayer-pathfinder"
import MinerChunk from "./chunk/MinerChunk";
import {Vec3} from "vec3";
//
// bot.on("spawn", async () => {
// const mcData = require("minecraft-data")(bot.version)
// bot.loadPlugin(pathfinder)
// await bot.waitForChunksToLoad()
// bot.chat("/login 1991455223")
// await bot.waitForTicks(20)
// bot.on("chat", async (username, message) => {
// // if (Date.now() - spamLock > 1000) {
// // spamLock = Date.now()
// // if (username != bot.username) {
// // // bot.chat("啊对对对" + Date.now())
// // checkPoint = !checkPoint
// // }
// // }
// if (username == "EnderTheCoder") {
// message = message.split(" ")[0]
// switch (message) {
// case "follow": {
// bot.chat("前往Master所在位置" + Date.now())
// bot.pathfinder.setGoal(new goals.GoalFollow(bot.players["EnderTheCoder"].entity, 1))
// break
// }
//
// case "teleport": {
// bot.chat("/tpa EnderTheCoder")
// break
// }
//
// case "scan": {
// bot.chat(Date.now() + "开始寻找目标范围内最近的钻石")
// let diamonds = bot.findBlocks({
// matching: mcData.blocksByName.diamond_ore.id,
// count: 10
// })
// await bot.waitForTicks(60)
//
// if (diamonds.length == 0) {
// bot.chat(Date.now() + "未发现目标")
// } else {
//
// for (let diamond of diamonds) {
// bot.chat("目标钻石坐标:(" + diamond.position.x + ", " + diamond.position.y + ", " + diamond.position.z + ")")
// await bot.waitForTicks(50)
// }
// }
// break
// }
// case "chunk": {
//
//
//
// break
// }
// }
// }
//
// }
// )
// })
let bot_manager = new BotManager()
let miner = bot_manager.createCustomBot("ender_bot", "www.bierdl.cn", 25565, "/login 1991455223")
miner.bot.on("messagestr", (message) => {
console.log(message)
})
miner.bot.on("chat", async (username, message) => {
// if (Date.now() - spamLock > 1000) {
// spamLock = Date.now()
// if (username != bot.username) {
// // bot.chat("啊对对对" + Date.now())
// checkPoint = !checkPoint
// }
// }
if (username == "EnderTheCoder") {
message = message.split(" ")[0]
switch (message) {
case "follow": {
miner.bot.chat("前往Master所在位置" + Date.now())
miner.bot.pathfinder.setGoal(new goals.GoalFollow(miner.bot.players["EnderTheCoder"].entity, 1))
break
}
case "teleport": {
miner.bot.chat("/tpa EnderTheCoder")
break
}
case "scan": {
miner.bot.chat(Date.now() + "开始寻找目标范围内最近的钻石")
let diamonds = miner.bot.findBlocks({
matching: miner.mcData.blocksByName.diamond_ore.id,
count: 10
})
await miner.bot.waitForTicks(60)
if (diamonds.length == 0) {
miner.bot.chat(Date.now() + "未发现目标")
} else {
for (let diamond of diamonds) {
miner.bot.chat("目标钻石坐标:(" + diamond.x + ", " + diamond.y + ", " + diamond.z + ")")
await miner.bot.waitForTicks(50)
}
}
break
}
case "chunk": {
console.log("chunk now")
let task_manager = new TaskManager(new MinerChunk(miner.bot.entity.position))
task_manager.addMiner(miner)
task_manager.start()
break
}
}
}
})
miner.bot.on("kicked", console.log)
// bot.once("windowOpen", (window)=>{window.cl})