/// Handles food consumption and shooting arrows.
Handles food consumption and shooting arrows.
Handles food consumption and shooting arrows .
fn handle_consume_item(
    packet: &PlayerDigging,
    player: &PlayerComponent,
    entity: Entity,
    inventory: &mut InventoryComponent,
    inventory_updates: &mut EventChannel<InventoryUpdateEvent>,
    position: Position,
    shoot_arrow_events: &mut EventChannel<ShootArrowEvent>,
) {
    assert_eq!(packet.status, PlayerDiggingStatus::ConsumeItem);
    // TODO: Fallback to off-hand if main-hand is not a consumable
    let used_item = inventory.item_in_main_hand();
    if let Some(item) = used_item {
        if item.ty == Item::Bow {
            handle_shoot_bow(
                player,
                entity,
                inventory,
                inventory_updates,
                position,
                shoot_arrow_events,
            );
        }
        // TODO: Food, potions
    }
}
fn handle_consume_item ( packet : & PlayerDigging , player : & PlayerComponent , entity : Entity , inventory : & mut InventoryComponent , inventory_updates : & mut EventChannel < InventoryUpdateEvent > , position : Position , shoot_arrow_events : & mut EventChannel < ShootArrowEvent > , ) { assert_eq ! ( packet status PlayerDiggingStatus ConsumeItem ) ; // TODO: Fallback to off-hand if main-hand is not a consumable let used_item = inventory . item_in_main_hand ( ) ; if let Some ( item ) = used_item { if item . ty == Item :: Bow { handle_shoot_bow ( player , entity , inventory , inventory_updates , position , shoot_arrow_events , ) ; } // TODO: Food, potions } }
Handles food consumption and shooting arrows.
Handles food consumption and shooting arrows .
packet
&PlayerDigging
player
&PlayerComponent
entity
Entity
inventory
&mut InventoryComponent
inventory_updates
&mut EventChannel<InventoryUpdateEvent>
position
Position
shoot_arrow_events
&mut EventChannel<ShootArrowEvent>