only allow ClickMode::Click

This commit is contained in:
Carson McManus 2023-06-06 10:26:11 -04:00
parent 0f8199eabb
commit db94ce78a3

View file

@ -11,7 +11,7 @@ use valence_core::protocol::encode::WritePacket;
use valence_core::text::Text; use valence_core::text::Text;
use crate::packet::{ use crate::packet::{
ClickSlotC2s, InventoryS2c, OpenScreenS2c, ScreenHandlerSlotUpdateS2c, WindowType, ClickMode, ClickSlotC2s, InventoryS2c, OpenScreenS2c, ScreenHandlerSlotUpdateS2c, WindowType,
}; };
use crate::{ use crate::{
validate, ClickSlot, ClientInventoryState, CursorItem, DropItemStack, Inventory, InventoryKind, validate, ClickSlot, ClientInventoryState, CursorItem, DropItemStack, Inventory, InventoryKind,
@ -52,6 +52,9 @@ fn handle_click_slot(
mut inventories: Query<&mut Inventory, (Without<Client>, With<InventoryMenu>)>, mut inventories: Query<&mut Inventory, (Without<Client>, With<InventoryMenu>)>,
) { ) {
for click in clicks.iter() { for click in clicks.iter() {
if click.mode != ClickMode::Click {
continue;
}
println!("menu click: {:?}", click); println!("menu click: {:?}", click);
if let Ok((mut client, mut inv, mut inv_state, mut cursor_item, open_inv)) = if let Ok((mut client, mut inv, mut inv_state, mut cursor_item, open_inv)) =
clients.get_mut(click.client) clients.get_mut(click.client)