pub struct BlockBreakingManager {
is_destroying_block: bool,
destroy_progress_start: u64,
destroy_pos: BlockPos,
game_ticks: u64,
has_delayed_destroy: bool,
delayed_destroy_pos: BlockPos,
delayed_tick_start: u64,
last_sent_state: i32,
}Expand description
Manages the block breaking state for a player.
Based on Java’s ServerPlayerGameMode fields and logic.
Fields§
§is_destroying_block: boolWhether the player is currently breaking a block.
destroy_progress_start: u64The tick when destruction started.
destroy_pos: BlockPosThe position of the block being destroyed.
game_ticks: u64The current game tick counter.
has_delayed_destroy: boolWhether there’s a delayed destroy pending (for slow mining).
delayed_destroy_pos: BlockPosPosition of the delayed destroy.
delayed_tick_start: u64The tick when delayed destroy started.
last_sent_state: i32The last sent destruction progress state (0-9, or -1 for none).
Implementations§
Source§impl BlockBreakingManager
impl BlockBreakingManager
Sourcepub fn tick(&mut self, player: &Player, world: &Arc<World>)
pub fn tick(&mut self, player: &Player, world: &Arc<World>)
Ticks the block breaking manager.
This handles delayed destruction and updates break progress.
Sourcefn increment_destroy_progress(
&mut self,
player: &Player,
world: &Arc<World>,
block_state: BlockStateId,
pos: BlockPos,
destroy_start_tick: u64,
) -> f32
fn increment_destroy_progress( &mut self, player: &Player, world: &Arc<World>, block_state: BlockStateId, pos: BlockPos, destroy_start_tick: u64, ) -> f32
Calculates and updates destruction progress, broadcasting to clients.
Sourcepub fn handle_block_break_action(
&mut self,
player: &Player,
world: &Arc<World>,
pos: BlockPos,
action: BlockBreakAction,
_direction: Direction,
)
pub fn handle_block_break_action( &mut self, player: &Player, world: &Arc<World>, pos: BlockPos, action: BlockBreakAction, _direction: Direction, )
Handles a block break action from the client.
Note: The caller (packet handler) is responsible for calling ack_block_changes_up_to
after this method returns, matching vanilla behavior.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BlockBreakingManager
impl RefUnwindSafe for BlockBreakingManager
impl Send for BlockBreakingManager
impl Sync for BlockBreakingManager
impl Unpin for BlockBreakingManager
impl UnsafeUnpin for BlockBreakingManager
impl UnwindSafe for BlockBreakingManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>