Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/plugins/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ function inject (bot, options) {

bot._client.once('update_health', (packet) => {
if (packet.health > 0) {
// Vanilla waits for this packet before accepting player actions. Send it
// before exposing spawn to callers, because spawn is Mineflayer's signal
// that they may begin interacting with the server.
if (bot.supportFeature('sendsPlayerLoadedPacket')) {
bot._client.write('player_loaded', {})
}
bot.emit('spawn')
}
})
Expand All @@ -28,6 +34,9 @@ function inject (bot, options) {
bot.respawn()
} else if (bot.health > 0 && !bot.isAlive) {
bot.isAlive = true
if (bot.supportFeature('sendsPlayerLoadedPacket')) {
bot._client.write('player_loaded', {})
}
bot.emit('spawn')
}
})
Expand Down
Loading