Fix
This commit is contained in:
parent
0a0835fd2d
commit
1d5f2112a7
@ -307,8 +307,8 @@ fn modify_field(packet_name: &str, field: output::Field) -> output::Field {
|
|||||||
}),
|
}),
|
||||||
("Success", "uuid") => field.change_type(output::DataType::Uuid { hyphenated: true }),
|
("Success", "uuid") => field.change_type(output::DataType::Uuid { hyphenated: true }),
|
||||||
("Disconnect", "reason") => field.change_type(output::DataType::Chat),
|
("Disconnect", "reason") => field.change_type(output::DataType::Chat),
|
||||||
("ClientBoundChatMessage", "message") => field.change_type(output::DataType::Chat),
|
("ClientBoundChat", "message") => field.change_type(output::DataType::Chat),
|
||||||
("ClientBoundChatMessage", "position") => field.change_type(output::DataType::RefType {
|
("ClientBoundChat", "position") => field.change_type(output::DataType::RefType {
|
||||||
ref_name: "MessagePosition".to_owned(),
|
ref_name: "MessagePosition".to_owned(),
|
||||||
}),
|
}),
|
||||||
_ => field,
|
_ => field,
|
||||||
|
@ -225,6 +225,20 @@ impl<R: Read> DecoderReadExt for R {
|
|||||||
read_signed_var_int!(i64, read_var_i64, 10);
|
read_signed_var_int!(i64, read_var_i64, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Encoder for i8 {
|
||||||
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
|
Ok(writer.write_i8(*self)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Decoder for i8 {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn decode<R: Read>(reader: &mut R) -> Result<Self::Output, DecodeError> {
|
||||||
|
Ok(reader.read_i8()?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Encoder for u8 {
|
impl Encoder for u8 {
|
||||||
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
Ok(writer.write_u8(*self)?)
|
Ok(writer.write_u8(*self)?)
|
||||||
@ -239,6 +253,20 @@ impl Decoder for u8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Encoder for i16 {
|
||||||
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
|
Ok(writer.write_i16::<BigEndian>(*self)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Decoder for i16 {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn decode<R: Read>(reader: &mut R) -> Result<Self::Output, DecodeError> {
|
||||||
|
Ok(reader.read_i16::<BigEndian>()?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Encoder for u16 {
|
impl Encoder for u16 {
|
||||||
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
Ok(writer.write_u16::<BigEndian>(*self)?)
|
Ok(writer.write_u16::<BigEndian>(*self)?)
|
||||||
@ -337,6 +365,34 @@ impl Decoder for bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Encoder for f32 {
|
||||||
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
|
Ok(writer.write_f32::<BigEndian>(*self)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Decoder for f32 {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn decode<R: Read>(reader: &mut R) -> Result<Self::Output, DecodeError> {
|
||||||
|
Ok(reader.read_f32::<BigEndian>()?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Encoder for f64 {
|
||||||
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
|
Ok(writer.write_f64::<BigEndian>(*self)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Decoder for f64 {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn decode<R: Read>(reader: &mut R) -> Result<Self::Output, DecodeError> {
|
||||||
|
Ok(reader.read_f64::<BigEndian>()?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Encoder for Vec<u8> {
|
impl Encoder for Vec<u8> {
|
||||||
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
Ok(writer.write_byte_array(self)?)
|
Ok(writer.write_byte_array(self)?)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// This file is automatically generated.
|
// This file is automatically generated.
|
||||||
// It is not intended for manual editing.
|
// It is not intended for manual editing.
|
||||||
|
use crate::data::chat::Message;
|
||||||
|
use crate::data::game::*;
|
||||||
use crate::DecodeError;
|
use crate::DecodeError;
|
||||||
use crate::Decoder;
|
use crate::Decoder;
|
||||||
use minecraft_protocol_derive::Packet;
|
use minecraft_protocol_derive::Packet;
|
||||||
@ -1641,7 +1643,7 @@ impl GameClientBoundPacket {
|
|||||||
Self::NbtQueryResponse(nbt_query_response)
|
Self::NbtQueryResponse(nbt_query_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn client_bound_chat(message: String, position: i8) -> Self {
|
pub fn client_bound_chat(message: Message, position: MessagePosition) -> Self {
|
||||||
let client_bound_chat = ClientBoundChat { message, position };
|
let client_bound_chat = ClientBoundChat { message, position };
|
||||||
|
|
||||||
Self::ClientBoundChat(client_bound_chat)
|
Self::ClientBoundChat(client_bound_chat)
|
||||||
@ -2892,8 +2894,8 @@ pub struct NbtQueryResponse {
|
|||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct ClientBoundChat {
|
pub struct ClientBoundChat {
|
||||||
pub message: String,
|
pub message: Message,
|
||||||
pub position: i8,
|
pub position: MessagePosition,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
// This file is automatically generated.
|
// This file is automatically generated.
|
||||||
// It is not intended for manual editing.
|
// It is not intended for manual editing.
|
||||||
|
use crate::data::chat::Message;
|
||||||
use crate::DecodeError;
|
use crate::DecodeError;
|
||||||
use crate::Decoder;
|
use crate::Decoder;
|
||||||
use std::io::Read;
|
|
||||||
use minecraft_protocol_derive::Packet;
|
use minecraft_protocol_derive::Packet;
|
||||||
|
use std::io::Read;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use crate::data::chat::Message;
|
|
||||||
|
|
||||||
pub enum LoginServerBoundPacket {
|
pub enum LoginServerBoundPacket {
|
||||||
LoginStart(LoginStart),
|
LoginStart(LoginStart),
|
||||||
EncryptionResponse(EncryptionResponse),
|
EncryptionResponse(EncryptionResponse),
|
||||||
LoginPluginResponse(LoginPluginResponse)
|
LoginPluginResponse(LoginPluginResponse),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginServerBoundPacket {
|
impl LoginServerBoundPacket {
|
||||||
@ -18,7 +18,7 @@ impl LoginServerBoundPacket {
|
|||||||
match self {
|
match self {
|
||||||
Self::LoginStart(_) => 0x00,
|
Self::LoginStart(_) => 0x00,
|
||||||
Self::EncryptionResponse(_) => 0x01,
|
Self::EncryptionResponse(_) => 0x01,
|
||||||
Self::LoginPluginResponse(_) => 0x02
|
Self::LoginPluginResponse(_) => 0x02,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,14 +39,12 @@ impl LoginServerBoundPacket {
|
|||||||
|
|
||||||
Ok(Self::LoginPluginResponse(login_plugin_response))
|
Ok(Self::LoginPluginResponse(login_plugin_response))
|
||||||
}
|
}
|
||||||
_ => Err(DecodeError::UnknownPacketType { type_id })
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn login_start(username: String) -> Self {
|
pub fn login_start(username: String) -> Self {
|
||||||
let login_start = LoginStart {
|
let login_start = LoginStart { username };
|
||||||
username
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::LoginStart(login_start)
|
Self::LoginStart(login_start)
|
||||||
}
|
}
|
||||||
@ -54,17 +52,14 @@ impl LoginServerBoundPacket {
|
|||||||
pub fn encryption_response(shared_secret: Vec<u8>, verify_token: Vec<u8>) -> Self {
|
pub fn encryption_response(shared_secret: Vec<u8>, verify_token: Vec<u8>) -> Self {
|
||||||
let encryption_response = EncryptionResponse {
|
let encryption_response = EncryptionResponse {
|
||||||
shared_secret,
|
shared_secret,
|
||||||
verify_token
|
verify_token,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::EncryptionResponse(encryption_response)
|
Self::EncryptionResponse(encryption_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn login_plugin_response(message_id: i32, data: Vec<u8>) -> Self {
|
pub fn login_plugin_response(message_id: i32, data: Vec<u8>) -> Self {
|
||||||
let login_plugin_response = LoginPluginResponse {
|
let login_plugin_response = LoginPluginResponse { message_id, data };
|
||||||
message_id,
|
|
||||||
data
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::LoginPluginResponse(login_plugin_response)
|
Self::LoginPluginResponse(login_plugin_response)
|
||||||
}
|
}
|
||||||
@ -75,7 +70,7 @@ pub enum LoginClientBoundPacket {
|
|||||||
EncryptionRequest(EncryptionRequest),
|
EncryptionRequest(EncryptionRequest),
|
||||||
Success(Success),
|
Success(Success),
|
||||||
Compress(Compress),
|
Compress(Compress),
|
||||||
LoginPluginRequest(LoginPluginRequest)
|
LoginPluginRequest(LoginPluginRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginClientBoundPacket {
|
impl LoginClientBoundPacket {
|
||||||
@ -85,7 +80,7 @@ impl LoginClientBoundPacket {
|
|||||||
Self::EncryptionRequest(_) => 0x01,
|
Self::EncryptionRequest(_) => 0x01,
|
||||||
Self::Success(_) => 0x02,
|
Self::Success(_) => 0x02,
|
||||||
Self::Compress(_) => 0x03,
|
Self::Compress(_) => 0x03,
|
||||||
Self::LoginPluginRequest(_) => 0x04
|
Self::LoginPluginRequest(_) => 0x04,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,41 +111,38 @@ impl LoginClientBoundPacket {
|
|||||||
|
|
||||||
Ok(Self::LoginPluginRequest(login_plugin_request))
|
Ok(Self::LoginPluginRequest(login_plugin_request))
|
||||||
}
|
}
|
||||||
_ => Err(DecodeError::UnknownPacketType { type_id })
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disconnect(reason: Message) -> Self {
|
pub fn disconnect(reason: Message) -> Self {
|
||||||
let disconnect = Disconnect {
|
let disconnect = Disconnect { reason };
|
||||||
reason
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::Disconnect(disconnect)
|
Self::Disconnect(disconnect)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encryption_request(server_id: String, public_key: Vec<u8>, verify_token: Vec<u8>) -> Self {
|
pub fn encryption_request(
|
||||||
|
server_id: String,
|
||||||
|
public_key: Vec<u8>,
|
||||||
|
verify_token: Vec<u8>,
|
||||||
|
) -> Self {
|
||||||
let encryption_request = EncryptionRequest {
|
let encryption_request = EncryptionRequest {
|
||||||
server_id,
|
server_id,
|
||||||
public_key,
|
public_key,
|
||||||
verify_token
|
verify_token,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::EncryptionRequest(encryption_request)
|
Self::EncryptionRequest(encryption_request)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn success(uuid: Uuid, username: String) -> Self {
|
pub fn success(uuid: Uuid, username: String) -> Self {
|
||||||
let success = Success {
|
let success = Success { uuid, username };
|
||||||
uuid,
|
|
||||||
username
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::Success(success)
|
Self::Success(success)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compress(threshold: i32) -> Self {
|
pub fn compress(threshold: i32) -> Self {
|
||||||
let compress = Compress {
|
let compress = Compress { threshold };
|
||||||
threshold
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::Compress(compress)
|
Self::Compress(compress)
|
||||||
}
|
}
|
||||||
@ -159,7 +151,7 @@ impl LoginClientBoundPacket {
|
|||||||
let login_plugin_request = LoginPluginRequest {
|
let login_plugin_request = LoginPluginRequest {
|
||||||
message_id,
|
message_id,
|
||||||
channel,
|
channel,
|
||||||
data
|
data,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::LoginPluginRequest(login_plugin_request)
|
Self::LoginPluginRequest(login_plugin_request)
|
||||||
@ -168,13 +160,13 @@ impl LoginClientBoundPacket {
|
|||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct LoginStart {
|
pub struct LoginStart {
|
||||||
pub username: String
|
pub username: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct EncryptionResponse {
|
pub struct EncryptionResponse {
|
||||||
pub shared_secret: Vec<u8>,
|
pub shared_secret: Vec<u8>,
|
||||||
pub verify_token: Vec<u8>
|
pub verify_token: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
@ -182,33 +174,32 @@ pub struct LoginPluginResponse {
|
|||||||
#[packet(with = "var_int")]
|
#[packet(with = "var_int")]
|
||||||
pub message_id: i32,
|
pub message_id: i32,
|
||||||
#[packet(with = "rest")]
|
#[packet(with = "rest")]
|
||||||
pub data: Vec<u8>
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct Disconnect {
|
pub struct Disconnect {
|
||||||
pub reason: Message
|
pub reason: Message,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct EncryptionRequest {
|
pub struct EncryptionRequest {
|
||||||
pub server_id: String,
|
pub server_id: String,
|
||||||
pub public_key: Vec<u8>,
|
pub public_key: Vec<u8>,
|
||||||
pub verify_token: Vec<u8>
|
pub verify_token: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct Success {
|
pub struct Success {
|
||||||
#[packet(with = "uuid_hyp_str")]
|
#[packet(with = "uuid_hyp_str")]
|
||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub username: String
|
pub username: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct Compress {
|
pub struct Compress {
|
||||||
#[packet(with = "var_int")]
|
#[packet(with = "var_int")]
|
||||||
pub threshold: i32
|
pub threshold: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
@ -217,6 +208,5 @@ pub struct LoginPluginRequest {
|
|||||||
pub message_id: i32,
|
pub message_id: i32,
|
||||||
pub channel: String,
|
pub channel: String,
|
||||||
#[packet(with = "rest")]
|
#[packet(with = "rest")]
|
||||||
pub data: Vec<u8>
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user