Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Send Ack in response to block placing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mubelotix committed Nov 8, 2023
1 parent 0043c82 commit e42d41b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions minecraft-server/src/player_handler/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ impl PlayerHandler {
self.world.set_block(location.into(), BlockWithState::Air).await;
}
}
PlaceBlock { hand, location, face, cursor_position_x, cursor_position_y, cursor_position_z, inside_block, sequence } => {
PlaceBlock { hand, location, face, sequence, .. } => {
use minecraft_protocol::components::blocks::BlockFace;

// TODO: use cursor position

// TODO: check legitimacy

let slot_id = match hand {
Hand::MainHand => self.held_item + 36,
Expand All @@ -192,15 +196,14 @@ impl PlayerHandler {
}

let text_id = item.item_id.text_id();
debug!("Client wants {text_id}");
let Some(block) = Block::from_text_id(text_id) else {return};
let Some(block) = BlockWithState::from_state_id(block.default_state_id()) else {return};
debug!("Placing {block:?}");

self.world.set_block(block_location.into(), block).await;
if self.game_mode != Gamemode::Creative {
item.item_count -= 1;
}
self.world.set_block(block_location.into(), block).await;
self.send_packet(PlayClientbound::AcknowledgeBlockChange { id: sequence }).await;
}
packet => warn!("Unsupported packet received: {packet:?}"),
}
Expand Down

0 comments on commit e42d41b

Please sign in to comment.