From bbbeb7ae2846b02122617f152bae363e93bf2784 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 22 Oct 2022 21:36:17 -0400 Subject: [PATCH] don't bother marking the inventory as dirty when handling SetCreativeModeSlot (#134) fixes #133 ### Test plan 1. run building example 2. open inventory 3. place any item in hotbar 4. try to pick it up 5. see that it does not disappear --- src/client/event.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/event.rs b/src/client/event.rs index c13174b..c606762 100644 --- a/src/client/event.rs +++ b/src/client/event.rs @@ -8,7 +8,7 @@ use crate::config::Config; use crate::entity::types::Pose; use crate::entity::{Entity, EntityEvent, EntityId, TrackedData}; use crate::ident::Ident; -use crate::inventory::Inventory; +use crate::inventory::{Inventory, InventoryDirtyable}; use crate::item::ItemStack; use crate::protocol::packets::c2s::play::ClickContainerMode; pub use crate::protocol::packets::c2s::play::{ @@ -348,7 +348,11 @@ pub fn handle_event_default( ClientEvent::DropItem => {} ClientEvent::DropItemStack { .. } => {} ClientEvent::SetSlotCreative { slot_id, slot } => { + let previous_dirty = client.inventory.is_dirty(); client.inventory.set_slot(*slot_id, slot.clone()); + // HACK: we don't need to mark the inventory as dirty because the + // client already knows what the updated state of the inventory is. + client.inventory.mark_dirty(previous_dirty); } ClientEvent::ClickContainer { .. } => {} ClientEvent::RespawnRequest => {}