Skip to content

Commit

Permalink
Added hit_result_component.miss as the condition to send mining eve…
Browse files Browse the repository at this point in the history
…nt and also send stop mining event if mining a block that is not reachable.
  • Loading branch information
AS1100K committed Jul 20, 2024
1 parent 7a71cb6 commit bcfdeaa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions azalea-client/src/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ fn handle_auto_mine(
),
(With<AutoMine>, With<Player>, With<LocalEntity>),
>,
mut start_mining_block_event_writer: EventWriter<StartMiningBlockEvent>,
mut start_mining_block_event: EventWriter<StartMiningBlockEvent>,
mut stop_mining_block_event: EventWriter<StopMiningBlockEvent>
) {
for (
hit_result_component,
Expand All @@ -119,18 +120,23 @@ fn handle_auto_mine(
{
let block_pos = hit_result_component.block_pos;

if mining.is_none()
if (mining.is_none()
|| !is_same_mining_target(
block_pos,
inventory,
current_mining_pos,
current_mining_item,
)
)) && !hit_result_component.miss
{
start_mining_block_event_writer.send(StartMiningBlockEvent {
start_mining_block_event.send(StartMiningBlockEvent {
entity,
position: block_pos,
});
} else if mining.is_some() && hit_result_component.miss {
// Stop mining as the block is not reachable
stop_mining_block_event.send(StopMiningBlockEvent {
entity
});
}
}
}
Expand Down

0 comments on commit bcfdeaa

Please sign in to comment.