Minecraft packets

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Minecraft packets

Post 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).
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: Minecraft packets

Post by szensk »

It's TCP? You're going to want to use LuaSocket.
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Re: Minecraft packets

Post 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?
bekey
Party member
Posts: 255
Joined: Tue Sep 03, 2013 6:27 pm

[]

Post by bekey »

-snip-
Last edited by bekey on Fri Jan 24, 2014 1:39 am, edited 2 times in total.
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Re: Minecraft packets

Post 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?
bekey
Party member
Posts: 255
Joined: Tue Sep 03, 2013 6:27 pm

[]

Post by bekey »

-snip-
Last edited by bekey on Fri Jan 24, 2014 1:38 am, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Minecraft packets

Post 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.
bekey
Party member
Posts: 255
Joined: Tue Sep 03, 2013 6:27 pm

[]

Post by bekey »

-snip-
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests