PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.87k stars 894 forks source link

Proxy + mineflayer #315

Open rom1504 opened 9 years ago

rom1504 commented 9 years ago

Would it be possible to make a proxy and plug mineflayer in it ? That way it would be possible to see with the vanilla client what the bot is doing. proxy examples :

idea from @Corgano

It would probably mean ignoring everything the vanilla client is saying

roblabla commented 9 years ago

I... oh god this is both a terrible and great idea XD.

So you'd use the minecraft client as a viewer for what the mineflayer bot is doing ?

rom1504 commented 9 years ago

@roblabla Yeah that's the idea. Not sure how doable that is, it seems easy and at the same time both mineflayer, node-minecraft-protocol, the vanilla server and the vanilla client were not meant for that at all so we'll see if that can work :D

deathcap commented 8 years ago

Sort of like https://github.com/zerowidth/golem? ("minecraft beta proxy · no longer maintained")

rom1504 commented 8 years ago

Yes exactly

On Thu, Feb 18, 2016, 02:02 deathcap notifications@github.com wrote:

Sort of like https://github.com/zerowidth/golem? ("minecraft beta proxy · no longer maintained")

— Reply to this email directly or view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/315#issuecomment-185486107 .

plexigras commented 6 years ago

this works but you cant do much since mineflayer isn't written to support this.

const version = '1.9.4'

const nmp  = require('minecraft-protocol')
const mineflayer = require('mineflayer')

const server = nmp.createServer({ port:25566, version })

server.on('login', connect)
function connect(client) {
  const bot = mineflayer.createBot({
    username: client.username,
    version,
    keepAlive: false,
    plugins: {
      physics: false
    }
  })
  bot._client.on('raw', (buffer, metadata) => {
    if (metadata.state !== 'play') return
    client.writeRaw(buffer)
  })
  client.on('raw', buffer => bot._client.writeRaw(buffer))
}
Wqrld commented 6 years ago

@plexigras how would you connect to another server using that code?

edit: nvm i cant think

plexigras commented 6 years ago

by setting the mineflayer.createBot options?

lluiscab commented 6 years ago

I'm trying to make the code @plexigras provided a few comments above and I'm running into a kind of strange issue. My client connects fine but it gets kicked by the real server 1-2 after login due to a timeout, so I'm guessing the real server expects some packet (keepAlive maybe) that my proxy isn't sending. I'd really appreciate some help.

One thing to mention is that this error doesn't happen when using this code from node-minecraft-protocol

My code can be seen here

lluiscab commented 6 years ago

Seems like this error is fixed just by modifying this line

client.on('raw', buffer => bot._client.writeRaw(buffer))

to


client.on('raw', (buffer, metadata) => {

    if(metadata.name === 'keep_alive') {
        if(buffer.toString('hex') === '0b0000000000000000') return;
    }

    // Send event to server
    bot._client.writeRaw(buffer)

})```
BitBuf commented 4 years ago

bump

rom1504 commented 4 years ago

do you mean you're interested to work on this @iBuyMountainDew ?

rob9315 commented 3 years ago

I am just going to leave this here, currently only actively developed for the 1.12.2 but many other versions should work too mcproxy

SinanAkkoyun commented 3 years ago

How about implementing all this in a fabric mod. I am also just thinking of controlling the bots via a fabric pinging system etc via a RESTFUL API.

What are your thoughts? Any better ideas than RESTFUL or some example codes?

SinanAkkoyun commented 3 years ago

And wouldn't it be much cooler to "jump into the bot" and control it rather the other way around? Maybe I just misunderstood you guys but both ideas sound awesome!

KaffinPX commented 3 years ago

I made it lol

MrZillaGold commented 3 years ago

https://github.com/SteveProxy/proxy