Skip to content

Commit 9e83e74

Browse files
committed
add block placing
1 parent 1ba2be8 commit 9e83e74

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

pumpkin/src/client/player_packet.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ use crate::{
88
};
99
use num_traits::FromPrimitive;
1010
use pumpkin_config::ADVANCED_CONFIG;
11+
use pumpkin_core::math::position::WorldPosition;
1112
use pumpkin_core::{
12-
math::{position::WorldPosition, vector3::Vector3, wrap_degrees},
13+
math::{vector3::Vector3, wrap_degrees},
1314
text::TextComponent,
1415
GameMode,
1516
};
@@ -18,9 +19,9 @@ use pumpkin_inventory::{InventoryError, WindowType};
1819
use pumpkin_protocol::server::play::{SCloseContainer, SSetPlayerGround, SUseItem};
1920
use pumpkin_protocol::{
2021
client::play::{
21-
Animation, CAcknowledgeBlockChange, CBlockUpdate, CEntityAnimation, CEntityVelocity,
22-
CHeadRot, CHurtAnimation, CPingResponse, CPlayerChatMessage, CUpdateEntityPos,
23-
CUpdateEntityPosRot, CUpdateEntityRot, FilterType,
22+
Animation, CAcknowledgeBlockChange, CEntityAnimation, CEntityVelocity, CHeadRot,
23+
CHurtAnimation, CPingResponse, CPlayerChatMessage, CUpdateEntityPos, CUpdateEntityPosRot,
24+
CUpdateEntityRot, FilterType,
2425
},
2526
server::play::{
2627
Action, ActionType, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport,
@@ -29,7 +30,7 @@ use pumpkin_protocol::{
2930
SUseItemOn, Status,
3031
},
3132
};
32-
use pumpkin_world::block::{BlockFace, BlockState};
33+
use pumpkin_world::block::{BlockFace, BlockId, BlockState};
3334
use pumpkin_world::global_registry;
3435

3536
use super::PlayerConfig;
@@ -543,17 +544,14 @@ impl Player {
543544
if let Ok(block_state_id) = BlockState::new(minecraft_id, None) {
544545
let entity = &self.living_entity.entity;
545546
let world = &entity.world;
547+
546548
world
547-
.broadcast_packet_all(&CBlockUpdate::new(
548-
&location,
549-
block_state_id.get_id_mojang_repr().into(),
550-
))
551-
.await;
552-
world
553-
.broadcast_packet_all(&CBlockUpdate::new(
554-
&WorldPosition(location.0 + face.to_offset()),
555-
block_state_id.get_id_mojang_repr().into(),
556-
))
549+
.set_block(
550+
WorldPosition(location.0 + face.to_offset()),
551+
BlockId {
552+
data: block_state_id.get_id_mojang_repr() as u16,
553+
},
554+
)
557555
.await;
558556
}
559557
}

0 commit comments

Comments
 (0)