Add Clientbound Block update
This commit is contained in:
parent
40fe40355f
commit
4562570f92
@ -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);
|
||||
|
||||
11
pumpkin-protocol/src/client/play/c_block_update.rs
Normal file
11
pumpkin-protocol/src/client/play/c_block_update.rs
Normal file
@ -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
|
||||
|
||||
@ -48,21 +48,17 @@ impl Vec3 {
|
||||
z: self.z * z,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mul(self, scalar: f64) -> Self {
|
||||
Vec3 {
|
||||
x: self.x * scalar,
|
||||
y: self.y * scalar,
|
||||
z: self.z * scalar,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<f64> for Vec3 {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, scalar: f64) -> Self {
|
||||
self.mul(scalar)
|
||||
Self {
|
||||
x: self.x * scalar,
|
||||
y: self.y * scalar,
|
||||
z: self.z * scalar,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user