Page 1 of 1

Minecraft packets

Posted: Sat Dec 21, 2013 3:02 pm
by jag_e_nummer_ett
This is so confusing... I tried using LUBE but the tutorials are outdated.. I try the normal luasocket but its documentation sucks (the ones I found).
It's so frustrating. Please if someone knows how to send a package to a minecraft server please leak that knowledge.

I can't even get how to make the luasocket to get a website or anything (and I am avoiding the socket.http).

Re: Minecraft packets

Posted: Sat Dec 21, 2013 4:13 pm
by szensk
It's TCP? You're going to want to use LuaSocket.

Re: Minecraft packets

Posted: Sat Dec 21, 2013 6:39 pm
by jag_e_nummer_ett
szensk wrote:You're going to want to use LuaSocket.
Good to know, so I don't try to glue myself to LUBE.
szensk wrote:It's TCP?
That's not what I meant.
I meant how to send a packet.
Ex the handshake (taken from here):
  • Packet ID: 0x00
    Protocol version: (VarInt) 4 as of 1.7.2
    Server address: (String) ex localhost
    Server port: (Unsigned Short) 25565
    Next state: (VarInt) 1 for status, 2 for login
Now how would I send such a message?
My first idea was something like this:

Code: Select all

connection:send(0x00)
connection:send(4)
connection:send(ip)
connection:send(port)
connection:send(2)
But that didnt quite work out.
What to do here?

[]

Posted: Sat Dec 21, 2013 6:54 pm
by bekey
-snip-

Re: Minecraft packets

Posted: Sat Dec 21, 2013 6:59 pm
by jag_e_nummer_ett
bekey wrote:

Code: Select all

connection:setHandshake("0x00" .. "4" .. "localhost" .. "25565" .. "2")
Now just to confirm, is it done by combining the fields? Shouldn't there be something separating them, like a space or comma?

[]

Posted: Sat Dec 21, 2013 7:00 pm
by bekey
-snip-

Re: Minecraft packets

Posted: Sat Dec 21, 2013 7:31 pm
by bartbes
I would definitely go with luasocket instead of lube, because lube does add a tiny bit of "structure", that's not necessarily compatible with minecraft's protocol.
I took a look at the protocol, and considering you're asking these questions, you're going to be in for a lot of fun..

Anyway, you'd want something like string.char(0x00, 0x04, 0x09).."localhost", string.char(0xDD, 0xC7, 0x01, 0x01), to do the status message for localhost and on port 25565.

The hard parts here are that the string is preceded by a varint containing the length, and then the varint containing the port. Now this is a varint, and yes, it's not that easy.

[]

Posted: Sat Dec 21, 2013 8:52 pm
by bekey
-snip-