mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
feat: prevent block placement at player's position
This commit is contained in:
@@ -177,7 +177,12 @@ void Player::update(float delta_time) {
|
||||
if (Input::get_input_state().mouse_state.right) {
|
||||
glm::ivec3 near_pos = m_look_block->pos + m_look_block->normal;
|
||||
if (!m_world.is_block(near_pos)) {
|
||||
m_world.set_block(near_pos, 1);
|
||||
glm::ivec3 p_pos = glm::floor(m_player_pos);
|
||||
p_pos.y += 1;
|
||||
if ((near_pos != p_pos) && (near_pos != (p_pos + glm::ivec3(0 ,1, 0)))) {
|
||||
m_world.set_block(near_pos, 1);
|
||||
}
|
||||
|
||||
}
|
||||
Input::get_input_state().mouse_state.right = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user