Pumpkin/pumpkin/src/net/bedrock/open_connection.rs
Alexander Medvedev 7a8f11b984 fix: https://github.com/Pumpkin-MC/Pumpkin/issues/2063
does not really fix the issue i guess, but at least you don't get the error anymore
2026-04-25 18:59:32 +02:00

56 lines
1.5 KiB
Rust

use std::net::SocketAddr;
use pumpkin_protocol::bedrock::{
client::raknet::{
incompatible_protocol::CIncompatibleProtocolVersion,
open_connection::{COpenConnectionReply1, COpenConnectionReply2},
},
server::raknet::open_connection::{SOpenConnectionRequest1, SOpenConnectionRequest2},
};
use pumpkin_world::CURRENT_BEDROCK_MC_PROTOCOL;
use tokio::net::UdpSocket;
use crate::{net::bedrock::BedrockClient, server::Server};
impl BedrockClient {
pub async fn handle_open_connection_1(
server: &Server,
packet: SOpenConnectionRequest1,
addr: SocketAddr,
socket: &UdpSocket,
) {
if packet.protocol_version != CURRENT_BEDROCK_MC_PROTOCOL as u8 {
Self::send_offline_packet(
&CIncompatibleProtocolVersion::new(
CURRENT_BEDROCK_MC_PROTOCOL as u8,
server.server_guid,
),
addr,
socket,
)
.await;
return;
}
Self::send_offline_packet(
&COpenConnectionReply1::new(server.server_guid, false, 1400),
addr,
socket,
)
.await;
}
pub async fn handle_open_connection_2(
server: &Server,
packet: SOpenConnectionRequest2,
addr: SocketAddr,
socket: &UdpSocket,
) {
Self::send_offline_packet(
&COpenConnectionReply2::new(server.server_guid, addr, packet.mtu, false),
addr,
socket,
)
.await;
}
}