Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix so cursor packet is sent to client with open inventories #653

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions crates/valence_inventory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,6 @@ fn update_player_inventories(
// Contrary to what you might think, we actually don't want to increment the
// state ID here because the client doesn't actually acknowledge the
// state_id change for this packet specifically. See #304.

client.write_packet(&ScreenHandlerSlotUpdateS2c {
window_id: -1,
state_id: VarInt(inv_state.state_id.0),
Expand All @@ -673,7 +672,7 @@ fn update_open_inventories(
Entity,
&mut Client,
&mut ClientInventoryState,
&CursorItem,
Ref<CursorItem>,
&mut OpenInventory,
)>,
mut inventories: Query<&mut Inventory>,
Expand Down Expand Up @@ -747,6 +746,18 @@ fn update_open_inventories(
}
}
}
if cursor_item.is_changed() && !inv_state.client_updated_cursor_item {
// Contrary to what you might think, we actually don't want to increment the
// state ID here because the client doesn't actually acknowledge the
// state_id change for this packet specifically. See #304.

client.write_packet(&ScreenHandlerSlotUpdateS2c {
window_id: -1,
state_id: VarInt(inv_state.state_id.0),
slot_idx: -1,
slot_data: Cow::Borrowed(&cursor_item.0),
});
}
}
}

Expand Down
Loading