mirror of
https://github.com/zyllian/classics.git
synced 2025-01-17 19:22:37 -08:00
add bounds check for block modification
This commit is contained in:
parent
167b8c6bf9
commit
a8decfa3db
1 changed files with 11 additions and 0 deletions
|
@ -226,6 +226,17 @@ async fn handle_stream_inner(
|
|||
} => {
|
||||
let block_type = if mode == 0x00 { 0 } else { block_type };
|
||||
let mut data = data.write().await;
|
||||
|
||||
// kick players if they attempt to place a block out of bounds
|
||||
if x.clamp(0, data.level.x_size as i16 - 1) != x
|
||||
|| y.clamp(0, data.level.y_size as i16 - 1) != y
|
||||
|| z.clamp(0, data.level.z_size as i16 - 1) != z
|
||||
{
|
||||
return Ok(Some(
|
||||
"Attempt to place block out of bounds".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let new_block_info = BLOCK_INFO.get(&block_type);
|
||||
let mut cancel = new_block_info.is_none();
|
||||
let block =
|
||||
|
|
Loading…
Add table
Reference in a new issue