Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

How to do a Minecraft Handshake [1.7.2]

Hey there,
I have got a problem: I want to code something like a status-checker for a minecraft server (After Minecraft 1.7)
I know, that I have to create a socket to the server:

Code
Socket skt = new Socket(IP, port);

This seems ok, the server is accepting the socket (Or at least, there is no error, while opening the socket)
Then I need to do the handshake! I found information that I need to send two different packets to the server, the 0x2-(Handshake)-Packet and the login packet. I found posts, where people were saying, that the minecraft server disconnectes the connection. But my server does not even react to my try:

Code
DataOutputStream writer = new DataOutputStream(
                    skt.getOutputStream());

writer.writeByte(0x2);
writer.writeByte(4);
writeString("127.0.0.1", writer);
writer.writeInt(25566);
writer.writeInt(2);
writer.flush();

Also I found different shapes for the packets. Often, they had unused bytes or some different information, like the login name. But what ever I tried, it didn't worked at all. SoI ask for anyone, who can send me a good tutorial how to do this handshake or anyone, who can explain, what I have to do!

BlackTechs
Its been a while since I messed with minecraft packets. But if I remember, any string in a packet had an int before it that was the length of the string.
Decompile Minecraft using MCP and there will be plenty of examples in there. They are doing rewrites of almost every class in the game to improve performance, so it will probably change once 1.8 comes out.
/*Edit*/
This might be helpful too...
Minecraft Protocol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Yeah well, decompiling does not help, because Minecraft uses about 112701234013 (just irony) different classes and stuff to do the client-server-protocoll. the protocol does not help anyway, it says what to do but not how to do!
I worked with the protocol and a decompiled minecraft for hours before I posted my thread. It just said nothing to me...

Edit:
Ah yes, I AM sending the size of the string within the packet! I am using a methode writeString(String) that sends first the size of the String, and then the string


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by ThinWhiteDukeOct 10, 2021 03:23 PM 2 107 Oct 10, 2021 03:23 PM
Last Post: ThinWhiteDuke
[.NET] by v.e.n.o.mApr 25, 2018 06:16 AM 3 178 Apr 25, 2018 06:16 AM
Last Post: Dalvik
[C] by Byte™Aug 8, 2017 12:35 AM 2 261 Aug 8, 2017 12:35 AM
Last Post: owonbo