Add Clientbound Block update
This commit is contained in:
1 parent
40fe40355f
commit
4562570f92
5 files changed
+32
-11
No files matched your search
@@ -29,7 +29,7 @@ impl<'a> CLoginSuccess<'a> {
|
||||
impl<'a> ClientPacket for CLoginSuccess<'a> {
|
||||
fn write(&self, bytebuf: &mut ByteBuffer) {
|
||||
bytebuf.put_uuid(self.uuid);
|
||||
bytebuf.put_string(&self.username);
|
||||
bytebuf.put_string(self.username);
|
||||
bytebuf.put_list::<Property>(self.properties, |p, v| {
|
||||
p.put_string(&v.name);
|
||||
p.put_string(&v.value);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use pumpkin_macros::packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{position::WorldPosition, VarInt};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[packet(0x09)]
|
||||
pub struct CBlockUpdate {
|
||||
location: WorldPosition,
|
||||
block_id: VarInt,
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
mod c_actionbar;
|
||||
mod c_block_update;
|
||||
mod c_center_chunk;
|
||||
mod c_change_difficulty;
|
||||
mod c_chunk_data;
|
||||
@@ -30,6 +31,7 @@ mod c_update_entity_rot;
|
||||
mod player_action;
|
||||
|
||||
pub use c_actionbar::*;
|
||||
pub use c_block_update::*;
|
||||
pub use c_center_chunk::*;
|
||||
pub use c_change_difficulty::*;
|
||||
pub use c_chunk_data::*;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub struct WorldPosition {
|
||||
x: i32,
|
||||
@@ -6,6 +6,18 @@ pub struct WorldPosition {
|
||||
z: i32,
|
||||
}
|
||||
|
||||
impl Serialize for WorldPosition {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
let long = ((self.x as i64 & 0x3FFFFFF) << 38)
|
||||
| ((self.z as i64 & 0x3FFFFFF) << 12)
|
||||
| (self.y as i64 & 0xFFF);
|
||||
serializer.serialize_i64(long)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for WorldPosition {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
|
||||
Reference in new issue
Block a user