mineflayer
mineflayer copied to clipboard
entityHurt event doesn't work
- [x] The FAQ doesn't contain a resolution to my issue
Versions
- mineflayer: 4.13.0
- server: vanilla/spigot/paper 1.20.1
- node: 18.15.0
Detailed description of a problem
The entityHurt
event is not called when attacking mobs.
What did you try yet?
I tried to:
- updating packages
- reinstalling node_modules
- updating/reinstalling paper server
Your current code
const bot = createBot({
host: 'localhost',
username: 'George',
});
bot.on('entityHurt', (entity) => {
console.log('test')
});
Expected behavior
The entityHurt
event should be called when attacking enemies or when player hurts himself.
vanilla/spigot/paper which one is it
On Sat, Sep 2, 2023, 09:55 Dominik Grudzień @.***> wrote:
- The FAQ https://github.com/PrismarineJS/mineflayer/blob/master/docs/FAQ.md doesn't contain a resolution to my issue
Versions
- mineflayer: 4.13.0
- server: vanilla/spigot/paper 1.20.1
- node: 18.15.0
Detailed description of a problem
The entityHurt event is not called when attacking mobs. What did you try yet?
I tried to:
- updating packages
- reinstalling node_modules
- updating/reinstalling paper server
Your current code
const bot = createBot({ host: 'localhost', username: 'George',}); bot.on('entityHurt', (entity) => { console.log('test')});
Expected behavior
The entityHurt event should be called when attacking enemies or when player hurts himself.
— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/3184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437SYQZKQZVIGB7TFE2DXYLQ5XANCNFSM6AAAAAA4INZOFI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
the paper server
bot._client.on("hurt_animation", (packet) => {
const entity = this.bot.entities[packet.entityId]
if (!entity) return
console.log(entity.name, "hurt")
})
or
bot._client.on("damage_event", (packet) => {
console.log(packet.entityId, packet.sourceTypeId, packet.sourceCauseId, packet.sourceDirectId, packet.sourcePosition)
})
honestly cba to make a pr
@WhoTho both examples don't work
Same on Vanilla 1.20.
bot._client.on("hurt_animation", (packet) => { const entity = this.bot.entities[packet.entityId] if (!entity) return console.log(entity.name, "hurt") })
or
bot._client.on("damage_event", (packet) => { console.log(packet.entityId, packet.sourceTypeId, packet.sourceCauseId, packet.sourceDirectId, packet.sourcePosition) })
honestly cba to make a pr
It works on Vanilla 1.20.4.
I use mineflayer
of Python version to get the packet from the protected member bot._client
.
@On(bot._client, 'damage_event')
def handle2(this, packet, *args):
print(packet)
And there are the outputs:
{'entityId': 3595, 'sourceTypeId': 31, 'sourceCauseId': 124, 'sourceDirectId': 124}
However, entityHurt
event is not emitted.
the entities plugin seems to not know about the damage_event packet and the older packets used to catch an entity being hurt are no longer called in the newer version (with the right arguments to cause a entityHurt even to be emitted)
Looks like a simple fix, just someone needs to do it.