简体   繁体   English

如何在 Minecraft 中发送/接收数据包?

[英]How to send/receive packets in Minecraft?

My Post is about Minecraft and its multiplayer servers.我的帖子是关于 Minecraft 及其多人服务器的。 I will mention often the information, which is given on this website: https://wiki.vg/Protocol#Login_Start .我会经常提到这个网站上提供的信息: https://wiki.vg/Protocol#Login_Start So, my question is quite a bit complicated I guess.所以,我想我的问题有点复杂。 Please take care, that I´m not yet very familiar with Streams.请注意,我对 Streams 还不是很熟悉。 I want to create my own "Chatbot" for Minecraft, which is able to join on every Server without opening the Minecraft launcher.我想为 Minecraft 创建我自己的“Chatbot”,它能够在不打开 Minecraft 启动器的情况下加入每个服务器。 But therefor my programm must receive and send packets.但是为此我的程序必须接收和发送数据包。

I know about the protocol, which I mentioned above.我知道上面提到的协议。 In generell, there are 2 big steps of joining on a Server.一般来说,加入服务器有两个大步骤。 The first is, to send a handShake and "ping-pong" to make a connection.第一种是发送握手和“乒乓”来建立连接。 The second step, probably the most complicated one, is to authenticate my account on this Server.第二步,可能是最复杂的一步,是在此服务器上验证我的帐户。 I´m supposed to send certain information to the server and get some information back.我应该向服务器发送某些信息并取回一些信息。 Of course, I use DataInput/DataOutputStreams for sending and receiving.当然,我使用DataInput/DataOutputStreams进行发送和接收。 Now the protocol above plays a major role, because it says what I have to send to the server and in which form.现在上面的协议起着重要的作用,因为它说明了我必须向服务器发送什么以及以何种形式发送。

Java sending handshake packets to minecraft server Java 向我的世界服务器发送握手包

The post above was very usefull for the first step, to create a connection, In fact, somebody has made a lot of effort for this post.上面的帖子对于第一步非常有用,创建连接,事实上,有人为这篇帖子付出了很多努力。 so I dont want to copy his code for my post, Please remember, that I used his code in my Project.所以我不想为我的帖子复制他的代码,请记住,我在我的项目中使用了他的代码。 so every line is the same (And his code works very well,), So.所以每一行都是一样的(而且他的代码工作得很好,),所以。 now you know everything about my situation, I ask the question how to send / receive packets with the information required to authenticate my client.现在您了解了我的情况,我问的问题是如何发送/接收包含验证我的客户端所需信息的数据包。

Hopefully you understood what i wanted to ask.希望你明白我想问什么。 Thanks for your time !谢谢你的时间 !

I'm not sure how much detail you're expecting from me, but all the packets you need to send to the minecraft server & the requests to mojangs authserver are outlined here .我不确定您希望我提供多少详细信息,但是您需要发送到 minecraft 服务器的所有数据包以及对 mojangs authserver 的请求都在此处列出。

As for the question & code you referenced, that's currently sending a handshake packet with nextstate set to 1 (status) which is only used for pinging the server, not connecting to it.至于您引用的问题和代码,当前发送的握手数据包的 nextstate 设置为 1(状态),仅用于 ping 服务器,而不是连接到服务器。 You'll need to set that to 2 (login) & follow the sequenced outlined in the link above instead of just sending a request & ping packets.您需要将其设置为 2(登录)并按照上面链接中概述的顺序进行操作,而不仅仅是发送请求和 ping 数据包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM