Closed imharvol closed 4 years ago
what is the villagerEntity
you are passing to bot.openVillager
?
Its an Object of Entity:
Entity {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
id: 69,
type: 'mob',
position: Vec3 { x: -542.5, y: 14, z: 1596.5 },
velocity: Vec3 { x: 0, y: -1.8369140625, z: 0 },
yaw: 3.3624858870453256,
pitch: 0.024543692606170175,
onGround: true,
height: 0,
effects: {},
equipment: [ <5 empty items> ],
heldItem: undefined,
isValid: true,
metadata: [
0, 300,
'', 0,
0, <1 empty item>,
20, 0,
0, 0,
<2 empty items>, 0,
<2 empty items>, 0,
0
],
uuid: undefined,
mobType: 'Villager',
displayName: 'Villager',
entityType: 120,
name: 'Villager',
kind: 'NPCs',
headPitch: -3.141592653589793
}
JSON.stringify:
{"_events":{},"_eventsCount":0,"id":69,"type":"mob","position":{"x":-542.5,"y":14,"z":1596.5},"velocity":{"x":0,"y":-1.8369140625,"z":0},"yaw":3.3624858870453256,"pitch":0.024543692606170175,"onGround":true,"height":0,"effects":{},"equipment":[null,null,null,null,null],"isValid":true,"metadata":[0,300,"",0,0,null,20,0,0,0,null,null,0,null,null,0,0],"mobType":"Villager","displayName":"Villager","entityType":120,"name":"Villager","kind":"NPCs","headPitch":-3.141592653589793}
Just tried on 1.12.2 and throws the same errors.
i can't figure out how this ever worked in the first place but it definitely did.
Not sure if this should be closed, I'm still getting an error (at least) in 1.8.8
Code:
const mineflayer = require('mineflayer')
function sleep (ms) {
return new Promise(resolve => {
setTimeout(resolve, ms)
})
}
const bot = mineflayer.createBot({
host: 'localhost',
port: 38293,
username: 'Player',
version: '1.8.8'
})
bot.on('spawn', async function (username, message) {
await sleep(1000)
const villagerEntityID = Object.keys(bot.entities).find(entity => {
entity = bot.entities[entity]
return entity.mobType === 'Villager'
})
const villagerEntity = bot.entities[villagerEntityID]
const villager = bot.openVillager(villagerEntity)
})
Error: error.log
I don't think that await sleep(1000)
is enough
It still happens even waiting 10s
what's the full error ? can you print villagerEntityID and villagerEntity ?
I don't understand, I don't see the error. you only got
/node_modules/minecraft-protocol/src/transforms/framing.js:67
} else { throw e }
nothing else ???
and why is village instance printed, is that related ?
ok got it,the openVillager callback was called wrong, fixed and released as 2.14.1
Versions
Detailed description of a problem
At first when I try to use
bot.openVillager(villagerEntity)
I get this error:Which is easy to solve (villager in 1.8 has a capital letter), but lets just comment that assert for simplicity. The problem comes when I try to run the code without that assert and I get this error:
I guess some changes broke backwards compatibility with 1.8 villagers.
Current code
Expected behavior
Shouldn't throw error