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
This commit is contained in:
Carson McManus 2022-10-22 21:36:17 -04:00 committed by GitHub
parent c683a0d94c
commit bbbeb7ae28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<C: Config>(
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 => {}