37 lines
998 B
TypeScript
37 lines
998 B
TypeScript
import { Client } from 'minecraft-protocol'
|
|
import Module from './Module'
|
|
|
|
export default class Combat extends Module {
|
|
|
|
private respawn: boolean = true
|
|
|
|
public mount() {
|
|
this.client.on('combat_event', packet => {
|
|
switch (packet.event) {
|
|
case 0:
|
|
this.logger.warn('fighting')
|
|
break
|
|
|
|
case 1:
|
|
this.logger.info('fighting entity %s', packet.entityId)
|
|
break
|
|
|
|
case 2:
|
|
this.logger.info('dead player %s by %s', packet.playerId, packet.entityId)
|
|
//TODO: is me ?
|
|
//TODO: print chat message
|
|
if (this.respawn) {
|
|
//TODO: use Life.respawn()
|
|
this.client.write('client_command', { action: 1 })
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
//TODO: respawn or disconnect
|
|
//TODO: aura
|
|
|
|
//TODO: Interact Entity
|
|
|
|
}
|