From 79ae392058e86cc395d56e404f6b166d605d6be5 Mon Sep 17 00:00:00 2001 From: suprohub Date: Tue, 31 Dec 2024 15:46:46 +0400 Subject: [PATCH] inventory interact --- pumpkin/src/net/packet/play.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pumpkin/src/net/packet/play.rs b/pumpkin/src/net/packet/play.rs index d05d46cd..2d8ddf0c 100644 --- a/pumpkin/src/net/packet/play.rs +++ b/pumpkin/src/net/packet/play.rs @@ -930,6 +930,18 @@ impl Player { .send_packet(&CEntityStatus::new(player.entity_id(), 9)) .await; + if player.gamemode.load() != GameMode::Creative { + let mut inventory = player.inventory().lock().await; + let item_count = &mut inventory.held_item_mut().as_mut().unwrap().item_count; + *item_count -= 1; + + if *item_count == 0 { + *inventory.held_item_mut() = None; + } + + drop(inventory); + } + player .set_health( player.living_entity.health.load(),