Skip to content

Commit becec55

Browse files
committed
Fix block breaking progress
1 parent 4d2a296 commit becec55

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

feather/common/src/block_break.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ pub struct DestroyStateChange(pub ValidBlockPosition, pub u8);
99

1010
use crate::{Game, World};
1111

12+
// Comparing to 0.7 ensures good feeling in the client
13+
pub const BREAK_THRESHOLD: f32 = 0.7;
14+
1215
#[derive(Clone)]
1316
pub enum BlockBreaker {
1417
Active(ActiveBreaker),
@@ -156,8 +159,7 @@ impl ActiveBreaker {
156159
}
157160
/// Check if the block has been damaged enough to break.
158161
pub fn can_break(&self) -> bool {
159-
// Comparing to 0.7 ensures good feeling in the client
160-
self.progress >= 0.7 - self.damage / 2.0
162+
self.progress >= BREAK_THRESHOLD - self.damage / 2.0
161163
}
162164
pub fn new(
163165
world: &mut World,
@@ -220,7 +222,7 @@ impl ActiveBreaker {
220222
if self.fake_finished {
221223
10
222224
} else {
223-
(self.progress * 9.0).round() as u8
225+
(self.progress / BREAK_THRESHOLD * 9.0).round() as u8
224226
}
225227
}
226228
pub fn finish(self) -> FinishedBreaker {

feather/server/src/systems/player_join.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ fn accept_new_player(game: &mut Game, server: &mut Server, client_id: ClientId)
104104

105105
client.send_window_items(&window);
106106

107+
let gamemode = Gamemode::Survival;
108+
107109
builder
108110
.add(client_id)
109111
.add(View::new(
110112
Position::default().chunk(),
111113
server.options.view_distance,
112114
))
113-
.add(Gamemode::Creative)
115+
.add(gamemode)
114116
.add(previous_gamemode)
115117
.add(Name::new(client.username()))
116118
.add(client.uuid())

0 commit comments

Comments
 (0)