Merge pull request #44 from StripedMonkey/spell_checker

Spell Checker
This commit is contained in:
Alexander Medvedev
2024-08-23 20:03:07 +01:00
committed by GitHub
13 changed files with 31 additions and 31 deletions

View File

@@ -6,16 +6,16 @@ use crate::VarInt;
#[derive(Serialize)]
#[packet(0x5A)]
pub struct CEntityVelocity<'a> {
entitiy_id: &'a VarInt,
entity_id: &'a VarInt,
velocity_x: i16,
velocity_y: i16,
velocity_z: i16,
}
impl<'a> CEntityVelocity<'a> {
pub fn new(entitiy_id: &'a VarInt, velocity_x: f32, velocity_y: f32, velocity_z: f32) -> Self {
pub fn new(entity_id: &'a VarInt, velocity_x: f32, velocity_y: f32, velocity_z: f32) -> Self {
Self {
entitiy_id,
entity_id,
velocity_x: (velocity_x.clamp(-3.9, 3.9) * 8000.0) as i16,
velocity_y: (velocity_y.clamp(-3.9, 3.9) * 8000.0) as i16,
velocity_z: (velocity_z.clamp(-3.9, 3.9) * 8000.0) as i16,

View File

@@ -6,12 +6,12 @@ use crate::VarInt;
#[derive(Serialize)]
#[packet(0x24)]
pub struct CHurtAnimation<'a> {
entitiy_id: &'a VarInt,
entity_id: &'a VarInt,
yaw: f32,
}
impl<'a> CHurtAnimation<'a> {
pub fn new(entitiy_id: &'a VarInt, yaw: f32) -> Self {
Self { entitiy_id, yaw }
pub fn new(entity_id: &'a VarInt, yaw: f32) -> Self {
Self { entity_id, yaw }
}
}

View File

@@ -7,14 +7,14 @@ use crate::VarInt;
#[packet(0x42)]
pub struct CRemoveEntities<'a> {
count: VarInt,
entitiy_ids: &'a [VarInt],
entity_ids: &'a [VarInt],
}
impl<'a> CRemoveEntities<'a> {
pub fn new(entitiy_ids: &'a [VarInt]) -> Self {
pub fn new(entity_ids: &'a [VarInt]) -> Self {
Self {
count: VarInt(entitiy_ids.len() as i32),
entitiy_ids,
count: VarInt(entity_ids.len() as i32),
entity_ids,
}
}
}

View File

@@ -5,7 +5,7 @@ use crate::VarInt;
#[derive(Serialize)]
#[packet(0x40)]
pub struct CSyncPlayerPostion {
pub struct CSyncPlayerPosition {
x: f64,
y: f64,
z: f64,
@@ -15,7 +15,7 @@ pub struct CSyncPlayerPostion {
teleport_id: VarInt,
}
impl CSyncPlayerPostion {
impl CSyncPlayerPosition {
pub fn new(
x: f64,
y: f64,

View File

@@ -4,12 +4,12 @@ use serde::Serialize;
#[derive(Serialize)]
#[packet(0x6C)]
pub struct CSystemChatMessge<'a> {
pub struct CSystemChatMessage<'a> {
content: TextComponent<'a>,
overlay: bool,
}
impl<'a> CSystemChatMessge<'a> {
impl<'a> CSystemChatMessage<'a> {
pub fn new(content: TextComponent<'a>, overlay: bool) -> Self {
Self { content, overlay }
}

View File

@@ -31,8 +31,8 @@ mod c_subtitle;
mod c_sync_player_position;
mod c_system_chat_message;
mod c_unload_chunk;
mod c_update_entitiy_pos_rot;
mod c_update_entity_pos;
mod c_update_entity_pos_rot;
mod c_update_entity_rot;
mod c_worldevent;
mod player_action;
@@ -70,8 +70,8 @@ pub use c_subtitle::*;
pub use c_sync_player_position::*;
pub use c_system_chat_message::*;
pub use c_unload_chunk::*;
pub use c_update_entitiy_pos_rot::*;
pub use c_update_entity_pos::*;
pub use c_update_entity_pos_rot::*;
pub use c_update_entity_rot::*;
pub use c_worldevent::*;
pub use player_action::*;

View File

@@ -143,7 +143,7 @@ pub enum PacketError {
#[error("packet length is out of bounds")]
OutOfBounds,
#[error("malformed packet length VarInt")]
MailformedLength,
MalformedLength,
}
#[derive(Debug, PartialEq)]

View File

@@ -28,7 +28,7 @@ impl PacketDecoder {
let packet_len = match VarInt::decode_partial(&mut r) {
Ok(len) => len,
Err(VarIntDecodeError::Incomplete) => return Ok(None),
Err(VarIntDecodeError::TooLarge) => Err(PacketError::MailformedLength)?,
Err(VarIntDecodeError::TooLarge) => Err(PacketError::MalformedLength)?,
};
if !(0..=MAX_PACKET_SIZE).contains(&packet_len) {

View File

@@ -13,7 +13,7 @@ pub struct SChatMessage {
pub timestamp: i64,
pub salt: i64,
pub signature: Option<Bytes>,
pub messagee_count: VarInt,
pub message_count: VarInt,
pub acknowledged: FixedBitSet,
}
@@ -25,7 +25,7 @@ impl ServerPacket for SChatMessage {
timestamp: bytebuf.get_i64(),
salt: bytebuf.get_i64(),
signature: bytebuf.get_option(|v| v.copy_to_bytes(256)),
messagee_count: bytebuf.get_var_int(),
message_count: bytebuf.get_var_int(),
acknowledged: bytebuf.get_fixed_bitset(20),
})
}

View File

@@ -5,7 +5,7 @@ use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
#[packet(0x25)]
pub struct SPlayerCommand {
pub entitiy_id: VarInt,
pub entity_id: VarInt,
pub action: VarInt,
pub jump_boost: VarInt,
}
@@ -16,8 +16,8 @@ pub enum Action {
LeaveBed,
StartSprinting,
StopSprinting,
StartHourseJump,
StopHourseJump,
StartHorseJump,
StopHorseJump,
OpenVehicleInventory,
StartFlyingElytra,
}
@@ -25,7 +25,7 @@ pub enum Action {
impl ServerPacket for SPlayerCommand {
fn read(bytebuf: &mut crate::bytebuf::ByteBuffer) -> Result<Self, DeserializerError> {
Ok(Self {
entitiy_id: bytebuf.get_var_int(),
entity_id: bytebuf.get_var_int(),
action: bytebuf.get_var_int(),
jump_boost: bytebuf.get_var_int(),
})

View File

@@ -19,7 +19,7 @@ use pumpkin_protocol::{
client::{
config::CConfigDisconnect,
login::CLoginDisconnect,
play::{CGameEvent, CPlayDisconnect, CSyncPlayerPostion, CSystemChatMessge},
play::{CGameEvent, CPlayDisconnect, CSyncPlayerPosition, CSystemChatMessage},
},
packet_decoder::PacketDecoder,
packet_encoder::PacketEncoder,
@@ -160,7 +160,7 @@ impl Client {
entity.yaw = yaw;
entity.pitch = pitch;
player.awaiting_teleport = Some(id.into());
self.send_packet(&CSyncPlayerPostion::new(x, y, z, yaw, pitch, 0, id.into()));
self.send_packet(&CSyncPlayerPosition::new(x, y, z, yaw, pitch, 0, id.into()));
}
pub fn update_health(&mut self, health: f32, food: i32, food_saturation: f32) {
@@ -362,7 +362,7 @@ impl Client {
}
pub fn send_system_message(&mut self, text: TextComponent) {
self.send_packet(&CSystemChatMessge::new(text, false));
self.send_packet(&CSystemChatMessage::new(text, false));
}
/// Kicks the Client with a reason depending on the connection state

View File

@@ -176,7 +176,7 @@ impl Client {
pub fn handle_player_command(&mut self, _server: &mut Server, command: SPlayerCommand) {
let player = self.player.as_mut().unwrap();
if command.entitiy_id != player.entity.entity_id.into() {
if command.entity_id != player.entity.entity_id.into() {
return;
}
@@ -187,8 +187,8 @@ impl Client {
pumpkin_protocol::server::play::Action::LeaveBed => todo!(),
pumpkin_protocol::server::play::Action::StartSprinting => player.sprinting = true,
pumpkin_protocol::server::play::Action::StopSprinting => player.sprinting = false,
pumpkin_protocol::server::play::Action::StartHourseJump => todo!(),
pumpkin_protocol::server::play::Action::StopHourseJump => todo!(),
pumpkin_protocol::server::play::Action::StartHorseJump => todo!(),
pumpkin_protocol::server::play::Action::StopHorseJump => todo!(),
pumpkin_protocol::server::play::Action::OpenVehicleInventory => todo!(),
pumpkin_protocol::server::play::Action::StartFlyingElytra => {} // TODO
}
@@ -317,7 +317,7 @@ impl Client {
}
if config.swing {}
} else {
self.kick("Interacted with invalid entitiy id")
self.kick("Interacted with invalid entity id")
}
}
}