mirror of
https://github.com/zyllian/classics.git
synced 2025-01-18 03:32:41 -08:00
This commit is contained in:
parent
bfb9d62f96
commit
614db37e38
4 changed files with 21 additions and 4 deletions
|
@ -85,6 +85,11 @@ impl PacketWriter {
|
|||
self.write_u8(b as u8)
|
||||
}
|
||||
|
||||
/// writes a bool to the packet
|
||||
fn write_bool(self, b: bool) -> Self {
|
||||
self.write_u8(if b { 1 } else { 0 })
|
||||
}
|
||||
|
||||
/// writes a u16 to the packet
|
||||
fn write_u16(self, sh: u16) -> Self {
|
||||
let mut s = self;
|
||||
|
@ -191,6 +196,11 @@ impl ExtBitmask {
|
|||
fn info(self) -> Option<ExtInfo> {
|
||||
// TODO: add entries as extensions are supported
|
||||
Some(match self {
|
||||
// this isn't actually used by the server at all, but it technically sort of implements it
|
||||
Self::HeldBlock => ExtInfo::new("HeldBlock".to_string(), 1, Self::HeldBlock),
|
||||
Self::EmoteFix => ExtInfo::new("EmoteFix".to_string(), 1, Self::EmoteFix),
|
||||
// TODO: render CP437 properly in server output
|
||||
Self::FullCP437 => ExtInfo::new("FullCP437".to_string(), 1, Self::FullCP437),
|
||||
Self::EnvWeatherType => {
|
||||
ExtInfo::new("EnvWeatherType".to_string(), 1, Self::EnvWeatherType)
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ pub enum ClientPacket {
|
|||
},
|
||||
/// sent to update the player's current position and orientation with the server
|
||||
PositionOrientation {
|
||||
/// should always be 0xff (-1), referring to the player who sent it
|
||||
_player_id: i8,
|
||||
/// if the HeldBlock extension is supported, this should contain the block the player is currently holding
|
||||
_player_id_or_held_block: i8,
|
||||
x: f16,
|
||||
y: f16,
|
||||
z: f16,
|
||||
|
@ -78,7 +78,7 @@ impl ClientPacket {
|
|||
block_type: buf.try_get_u8().ok()?,
|
||||
},
|
||||
0x08 => Self::PositionOrientation {
|
||||
_player_id: buf.try_get_i8().ok()?,
|
||||
_player_id_or_held_block: buf.try_get_i8().ok()?,
|
||||
x: buf.try_get_f16().ok()?,
|
||||
y: buf.try_get_f16().ok()?,
|
||||
z: buf.try_get_f16().ok()?,
|
||||
|
|
|
@ -99,6 +99,8 @@ pub enum ServerPacket {
|
|||
ExtInfo {},
|
||||
/// packet to send info about an extension on the server
|
||||
ExtEntry { ext_name: String, version: i32 },
|
||||
/// packet to set a player's currently held block
|
||||
HoldThis { block: u8, prevent_change: bool },
|
||||
/// informs the client that it should update the current weather
|
||||
EnvWeatherType { weather_type: WeatherType },
|
||||
}
|
||||
|
@ -125,6 +127,7 @@ impl ServerPacket {
|
|||
|
||||
Self::ExtInfo {} => 0x10,
|
||||
Self::ExtEntry { .. } => 0x11,
|
||||
Self::HoldThis { .. } => 0x14,
|
||||
Self::EnvWeatherType { .. } => 0x1f,
|
||||
}
|
||||
}
|
||||
|
@ -242,6 +245,10 @@ impl ServerPacket {
|
|||
Self::ExtEntry { ext_name, version } => {
|
||||
writer.write_string(ext_name).write_i32(*version)
|
||||
}
|
||||
Self::HoldThis {
|
||||
block,
|
||||
prevent_change,
|
||||
} => writer.write_u8(*block).write_bool(*prevent_change),
|
||||
Self::EnvWeatherType { weather_type } => writer.write_u8(weather_type.into()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ async fn handle_stream_inner(
|
|||
}
|
||||
}
|
||||
ClientPacket::PositionOrientation {
|
||||
_player_id: _,
|
||||
_player_id_or_held_block: _,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
|
|
Loading…
Add table
Reference in a new issue