Skip to main content

use_item_on

Function use_item_on 

Source
pub fn use_item_on(
    player: &Player,
    world: &Arc<World>,
    hand: InteractionHand,
    hit_result: &BlockHitResult,
) -> InteractionResult
Expand description

Handles using an item on a block.

This implements the logic from Java’s ServerPlayerGameMode.useItemOn().

§Flow

  1. Spectator mode: Only allow opening menus (currently returns Pass)
  2. Check if block interaction should be suppressed (sneaking + holding items)
  3. If not suppressed: Call block’s use_item_on method
  4. If block returns TryEmptyHandInteraction and main hand: Call block’s use_without_item
  5. If item not empty: Call item behavior’s use_on for placement
  6. Handle creative mode infinite materials