rewrite varints + varlongs
This commit is contained in:
parent
f8196d036c
commit
4b7af49ad0
10 changed files with 294 additions and 327 deletions
|
@ -15,10 +15,10 @@ fn send_handshake(
|
|||
next_state: u8
|
||||
) -> Result<(), ProtocolError> {
|
||||
conn.write_packet(&Packet::build(0x00, |packet| {
|
||||
packet.write_u16_varint(protocol_version)?;
|
||||
packet.write_varint(protocol_version as i32)?;
|
||||
packet.write_string(server_address)?;
|
||||
packet.write_unsigned_short(server_port)?;
|
||||
packet.write_u8_varint(next_state)
|
||||
packet.write_varint(next_state as i32)
|
||||
})?)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ fn main() -> Result<(), ProtocolError> {
|
|||
let mut conn = MCConnTcp::connect("localhost:25565")?; // connecting
|
||||
|
||||
conn.write_packet(&Packet::build(0x00, |packet| {
|
||||
packet.write_u16_varint(765)?; // protocol_version
|
||||
packet.write_varint(765)?; // protocol_version
|
||||
packet.write_string("localhost")?; // server_address
|
||||
packet.write_unsigned_short(25565)?; // server_port
|
||||
packet.write_u8_varint(1) // next_state
|
||||
packet.write_varint(1) // next_state
|
||||
})?)?; // handshake packet
|
||||
|
||||
conn.write_packet(&Packet::empty(0x00))?; // status request packet
|
||||
|
|
|
@ -63,10 +63,10 @@ impl MinecraftServer {
|
|||
)?)?;
|
||||
}
|
||||
} else if packet.id() == 0x00 {
|
||||
let protocol_version = packet.read_i32_varint()?;
|
||||
let protocol_version = packet.read_varint()?;
|
||||
let server_address = packet.read_string()?;
|
||||
let server_port = packet.read_unsigned_short()?;
|
||||
let next_state = packet.read_u8_varint()?;
|
||||
let next_state = packet.read_varint()?;
|
||||
|
||||
if next_state != 1 { break; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue