Skip to content

Commit 03d8c53

Browse files
Create index.js
1 parent 821cdd1 commit 03d8c53

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lookAt_Bot/index.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const mineflayer = require('mineflayer')
2+
3+
const bot = mineflayer.createBot({
4+
host: 'localhost',
5+
port: 37269,
6+
username: 'lookAt_Bot'
7+
})
8+
9+
function lookAtNearestPlayer () {
10+
const playerFilter = (entity) => entity.type === 'player'
11+
const playerEntity = bot.nearestEntity(playerFilter)
12+
13+
if (!playerEntity) return
14+
15+
const pos = playerEntity.position.offset(0, playerEntity.height, 0)
16+
bot.lookAt(pos)
17+
}
18+
19+
bot.on('physicTick', lookAtNearestPlayer)

0 commit comments

Comments
 (0)