Open ShiniPantz opened 1 year ago
Full code
const mineflayer = require('mineflayer')
const readline = require('readline')
const nbt = require('prismarine-nbt')
const { syncBuiltinESMExports } = require('module')
const exist=()=>{
const bot = mineflayer.createBot ({
host:process.argv[3],
port:parseInt(process.argv[5]),
version: "1.12.2",
auth:process.argv[4],
username:process.argv[2]
//password:
})
return bot
}
const login=()=>{
console.log("b")
const bot=exist()
bot.once("spawn",()=>{
console.log("beep boob")
readLineFromTerminal()
})
bot.on("particle",(krümel)=>{
console.log(krümel)
console.log("test")
})
bot.on("chat",()=>{
console.log("test")
})
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function readLineFromTerminal(){
rl.question("",function (text){
bot.chat(text)
console.log(eval(text))
readLineFromTerminal()
})
}
let id = 1
let brick = false
async function trade(id) {
const Olaf = bot.nearestEntity(entity => entity.metadata[2] == "Olaf") //declare Olaf as nearest Villager with nametag "Olaf"
const OlafMenu = await bot.openVillager(Olaf)
console.log(OlafMenu.trades[id])
if (!brick) {
if (OlafMenu.trades[id].tradeDisabled) {
console.log("bricked Villager")
brick = true
OlafMenu.close()
}
else {
amount = OlafMenu.maximumNbTradeUses - OlafMenu.nbTradeUses
await bot.trade(OlafMenu,id,amount)
setTimeout(OlafMenu.close,1000)
}
}
}
const loggecr = (name,text)=> {
if (name==="whispers"){}
else {
console.log("<"+name+"> "+text)
}
}
const loggecw = (name,text)=> {
console.log("<"+name+"> whispers "+text)
}
bot.on("chat",loggecr)
bot.on("whisper",loggecw)
function kickf (info,info2) {
console.log(info)
console.log(info2)
bot.end()
setTimeout(login, 60000)
}
bot.on("kicked",kickf)
bot.on("error",kickf)
}
login()
In case I fucked up something obvious
So it seems like the 4.5.1 version of mineflayer from npm is "outdated", and the 4.5.1 version on github is up to date. And apparently the npm version doesn't have the particle code yet. Kinda weird to me that there are 2 versions of 4.5.1 out there, I always thought the point of version numbers is to know which version is outdated, and which one is up to date, in a way where one can always go back to older versions with the old version number. But seems like the newest version gets constantly overwritten. I guess that's just how it it.
So maybe someone may somehow update the npm version of mineflayer?
So I tried listening to bot._client.on("world_particle".. I also tried manually updating mineflayer to include the particle stuff. Both approaches didn't work sadly.
Is this still an issue?
yes, I updated mineflayer, to 4.8.0 using npm, nothing changed. I tested with water bubbles and happy villager particles, for both bot.on("particle" and bot._client.on("world_particle"
I wanna note that the particle documentation in https://mineflayer.prismarine.js.org/#/api is either incomplete or false
Versions
Detailed description of a problem
The bot straight up ignores particles. I also have no idea how to get access to Particle instances, when the particle event doesn't even give me the particle Instance according to the api. But it doesn't even work at all.
What did you try yet?
My bot is standing next to an enchantment table with bookshelfs, doesn't detect the etable particles. I also tried water, bubbles, potion effects, villager trade reset particles, the bot just ignores them. Every other event, like "chat", does work.
Your current code
does not work, as well as
Expected behavior
I expect the message
to appear in my terminal. Like rapid fire "test" messages, considering the amount of particles there are. If possible, I would also like to put the particle instance into the pinstance variable, to be able to further inspect the particles.
Additional context
I tried asking in the mineflayer discord, they told me to open an issue on github.