我确实看过将数据包发送到 Minecraft 服务器的问题:Objective-C
如果他们在此处使用此链接,则可能是相关的:Protocol - Minecraft Server但是,他们没有使用该链接。他们使用主要用于一般信息的 wiki。我引用的是创建一个新客户端。但是,当我在 IRC 上询问时。他们说话就像我什么都不知道一样。所以,我在这里问。
How do i Send the packet correctly with the fields to Minecraft server?
请注意,Minecraft 服务器的代码在网站上。
我拥有的代码,连接到服务器,Minecraft 服务器上的输出如下所示:
[INFO] Disconnecting /192.168.1.4:60911: Took too long to log in
[INFO] Disconnecting /192.168.1.4:60915: Took too long to log in
[INFO] Disconnecting /192.168.1.4:60927: Took too long to log in
[INFO] /192.168.1.4:60934 lost connection
[INFO] Disconnecting /192.168.1.4:60954: Took too long to log in
我如何正确发送这些数据包?
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
unsigned char *ch[] = {0x02, [[defs stringForKey:@"Username"] UTF8String]};
UInt8 i = (UInt8)ch;
NSData *requestData = [NSData dataWithBytes:&i length:sizeof(i)];
NSString *reqLog = [[NSString alloc] initWithData:requestData encoding:NSUTF8StringEncoding];
[asyncsocket writeData:requestData withTimeout:-1.0 tag:0];
//[asyncsocket readDataToData:[GCDAsyncSocket LFData] withTimeout:-1.0 tag:0];
[asyncsocket readDataToLength:5 withTimeout:-1.0 tag:0];
/*NSData *responseTerminatorData = [@"\n" dataUsingEncoding:NSASCIIStringEncoding];
[asyncsocket readDataToData:responseTerminatorData withTimeout:-1.0 tag:0];*/
最后说明:IOS5 是此应用程序的平台