add creative pick item to packet SClickContainer
This commit is contained in:
parent
e0157663ed
commit
0f9ac2259c
@ -65,6 +65,8 @@ pub trait Container {
|
|||||||
slot: usize,
|
slot: usize,
|
||||||
mouse_click: MouseClick,
|
mouse_click: MouseClick,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fn all_slots(&mut self) -> Vec<&mut Option<ItemStack>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_item_take(
|
pub fn handle_item_take(
|
||||||
@ -173,4 +175,8 @@ impl<const T: usize> Container for ContainerStruct<T> {
|
|||||||
let current_slot = &mut self.slots[slot];
|
let current_slot = &mut self.slots[slot];
|
||||||
handle_item_change(carried_slot, current_slot, mouse_click)
|
handle_item_change(carried_slot, current_slot, mouse_click)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn all_slots(&mut self) -> Vec<&mut Option<ItemStack>> {
|
||||||
|
self.slots.iter_mut().collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,4 +144,8 @@ impl Container for PlayerInventory {
|
|||||||
let item_slot = self.get_slot(slot);
|
let item_slot = self.get_slot(slot);
|
||||||
handle_item_change(carried_slot, item_slot, mouse_click)
|
handle_item_change(carried_slot, item_slot, mouse_click)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn all_slots(&mut self) -> Vec<&mut Option<ItemStack>> {
|
||||||
|
self.slots_mut()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,7 +148,18 @@ impl Player {
|
|||||||
unimplemented!("This is not a valid state")
|
unimplemented!("This is not a valid state")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => todo!(),
|
ClickType::CreativePickItem => {
|
||||||
|
if let container_click::Slot::Normal(slot) = click.mode.slot {
|
||||||
|
self.creative_pick_item(slot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClickType::DoubleClick => {}
|
||||||
|
ClickType::MouseDrag {
|
||||||
|
drag_state,
|
||||||
|
drag_type,
|
||||||
|
} => {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dbg!(&self.carried_item);
|
dbg!(&self.carried_item);
|
||||||
let filled_inventory_slots = self
|
let filled_inventory_slots = self
|
||||||
@ -225,7 +236,6 @@ impl Player {
|
|||||||
}
|
}
|
||||||
container_click::Slot::OutsideInventory => (),
|
container_click::Slot::OutsideInventory => (),
|
||||||
};
|
};
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -252,6 +262,22 @@ impl Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn creative_pick_item(&mut self, slot: usize) {
|
||||||
|
let mut container = {
|
||||||
|
match &mut self.open_container {
|
||||||
|
Some(container) => {
|
||||||
|
let mut out = container.all_slots();
|
||||||
|
out.extend(self.inventory.slots_mut());
|
||||||
|
out
|
||||||
|
}
|
||||||
|
None => self.inventory.slots_mut(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(Some(item)) = container.get_mut(slot) {
|
||||||
|
self.carried_item = Some(item.to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*impl<const SLOTS: usize> ContainerStruct<SLOTS> {
|
/*impl<const SLOTS: usize> ContainerStruct<SLOTS> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user