works on 1.19.3 now
This commit is contained in:
parent
0f067d6114
commit
8434884747
4 changed files with 27 additions and 28 deletions
|
@ -3,7 +3,9 @@ use std::{net::{TcpListener, SocketAddr}, thread, sync::mpsc::{Receiver, Sender,
|
|||
use log::{info, warn, debug};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{protocol::{data::PacketEncoder, serverbound::*, clientbound::*, command::{Commands, CommandNodeType}}, plugins::{Plugins, Response}, VERSION};
|
||||
use crate::protocol::{data::PacketEncoder, serverbound::*, clientbound::*, command::Commands, Position};
|
||||
use crate::plugins::{Plugins, Response};
|
||||
use crate::VERSION;
|
||||
|
||||
use super::{client::NetworkClient, Player};
|
||||
|
||||
|
@ -142,7 +144,7 @@ impl <'lua> NetworkServer<'lua> {
|
|||
ServerBoundPacket::Handshake(_) => (),
|
||||
ServerBoundPacket::StatusRequest()
|
||||
=> client.send_packet(ClientBoundPacket::StatusResponse(
|
||||
r#"{"version":{"name":"1.19.2","protocol":760}}"#.to_owned()
|
||||
r#"{"version":{"name":"1.19.3","protocol":761}}"#.to_owned()
|
||||
))?,
|
||||
ServerBoundPacket::PingRequest(n) => {
|
||||
client.send_packet(ClientBoundPacket::PingResponse(n))?;
|
||||
|
@ -240,6 +242,9 @@ impl <'lua> NetworkServer<'lua> {
|
|||
heightmap,
|
||||
chunk_data,
|
||||
}))?;
|
||||
client.send_packet(ClientBoundPacket::SetDefaultSpawnPosition(
|
||||
Position { x: 0, y: 0, z: 0 }, 0.0
|
||||
))?;
|
||||
client.send_packet(ClientBoundPacket::SyncPlayerPosition(SyncPlayerPosition {
|
||||
x: 0.0,
|
||||
y: 64.0,
|
||||
|
|
|
@ -153,6 +153,7 @@ pub enum ClientBoundPacket {
|
|||
KeepAlive(i64),
|
||||
PlayerAbilities(i8, f32, f32),
|
||||
Disconnect(serde_json::Value),
|
||||
SetDefaultSpawnPosition(Position, f32),
|
||||
SystemChatMessage(serde_json::Value, bool),
|
||||
}
|
||||
|
||||
|
@ -181,42 +182,47 @@ impl ClientBoundPacket {
|
|||
// Play
|
||||
Self::Disconnect(message) => {
|
||||
packet.write_string(262144, &message.to_string());
|
||||
finalize_packet(packet, 25)
|
||||
finalize_packet(packet, 23)
|
||||
}
|
||||
Self::LoginPlay(login_play) => {
|
||||
login_play.encode(&mut packet);
|
||||
finalize_packet(packet, 37)
|
||||
finalize_packet(packet, 36)
|
||||
}
|
||||
Self::PluginMessage(plugin_message) => {
|
||||
plugin_message.encode(&mut packet);
|
||||
finalize_packet(packet, 22)
|
||||
finalize_packet(packet, 21)
|
||||
}
|
||||
Self::Commands(commands) => {
|
||||
commands.encode(&mut packet);
|
||||
finalize_packet(packet, 15)
|
||||
finalize_packet(packet, 14)
|
||||
}
|
||||
Self::ChunkData(chunk_data) => {
|
||||
chunk_data.encode(&mut packet);
|
||||
finalize_packet(packet, 33)
|
||||
finalize_packet(packet, 32)
|
||||
}
|
||||
Self::SyncPlayerPosition(sync_player_position) => {
|
||||
sync_player_position.encode(&mut packet);
|
||||
finalize_packet(packet, 57)
|
||||
finalize_packet(packet, 56)
|
||||
}
|
||||
Self::KeepAlive(n) => {
|
||||
packet.write_long(n);
|
||||
finalize_packet(packet, 32)
|
||||
finalize_packet(packet, 31)
|
||||
}
|
||||
Self::SetDefaultSpawnPosition(pos, angle) => {
|
||||
packet.write_position(pos);
|
||||
packet.write_float(angle);
|
||||
finalize_packet(packet, 76)
|
||||
}
|
||||
Self::PlayerAbilities(flags, speed, view) => {
|
||||
packet.write_byte(flags);
|
||||
packet.write_float(speed);
|
||||
packet.write_float(view);
|
||||
finalize_packet(packet, 49)
|
||||
finalize_packet(packet, 48)
|
||||
}
|
||||
Self::SystemChatMessage(msg, overlay) => {
|
||||
packet.write_string(262144, &msg.to_string());
|
||||
packet.write_bool(overlay);
|
||||
finalize_packet(packet, 98)
|
||||
finalize_packet(packet, 96)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ pub enum NetworkState {
|
|||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Position {
|
||||
x: i32,
|
||||
y: i16,
|
||||
z: i32
|
||||
pub x: i32,
|
||||
pub y: i16,
|
||||
pub z: i32
|
||||
}
|
||||
|
|
|
@ -30,30 +30,18 @@ pub struct SigData {
|
|||
#[derive(Debug)]
|
||||
pub struct LoginStart {
|
||||
pub name: String,
|
||||
pub sig_data: Option<SigData>,
|
||||
pub uuid: Uuid,
|
||||
}
|
||||
|
||||
impl LoginStart {
|
||||
pub fn decode(mut decoder: PacketDecoder) -> Self {
|
||||
let name = decoder.read_string();
|
||||
let has_sig_data = decoder.read_bool();
|
||||
let sig_data = if has_sig_data {
|
||||
let timestamp = decoder.read_long();
|
||||
let pubkey_len = decoder.read_varint();
|
||||
let pubkey = decoder.read_bytes(pubkey_len as usize).to_vec();
|
||||
let sig_len = decoder.read_varint();
|
||||
let sig = decoder.read_bytes(sig_len as usize).to_vec();
|
||||
Some(SigData { timestamp, pubkey, sig })
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let has_uuid = decoder.read_bool();
|
||||
if !has_uuid {
|
||||
panic!("Client didn't supply UUID");
|
||||
}
|
||||
let uuid = decoder.read_uuid();
|
||||
Self { name, sig_data, uuid }
|
||||
Self { name, uuid }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +99,7 @@ impl ServerBoundPacket {
|
|||
},
|
||||
(NS::Play, 4) => ServerBoundPacket::ChatCommand(ChatMessage::decode(decoder)),
|
||||
(NS::Play, 5) => ServerBoundPacket::ChatMessage(ChatMessage::decode(decoder)),
|
||||
(NS::Play, id @ (18 | 20 | 21 | 22 | 30)) => ServerBoundPacket::Ignored(id),
|
||||
(NS::Play, id @ (17 | 19 | 20 | 21 | 29)) => ServerBoundPacket::Ignored(id),
|
||||
(_, id) => ServerBoundPacket::Unknown(id),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue