make block place the item that is held.
This commit is contained in:
5 files changed
+40
-8
No files matched your search
@@ -5,6 +5,6 @@ use crate::slot::Slot;
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
#[packet(0x32)]
|
||||
pub struct SSetCreativeSlot {
|
||||
slot: i16,
|
||||
clicked_item: Slot,
|
||||
pub slot: i16,
|
||||
pub clicked_item: Slot,
|
||||
}
|
||||
@@ -2,7 +2,7 @@ use serde::{
|
||||
de::{self, SeqAccess, Visitor},
|
||||
Deserialize,
|
||||
};
|
||||
|
||||
use pumpkin_world::item::Item;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -15,6 +15,9 @@ pub struct Slot {
|
||||
components_to_remove: Option<Vec<VarInt>>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
impl<'de> Deserialize<'de> for Slot {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
@@ -74,3 +77,20 @@ impl<'de> Deserialize<'de> for Slot {
|
||||
deserializer.deserialize_seq(VarIntVisitor)
|
||||
}
|
||||
}
|
||||
impl Slot {
|
||||
pub fn to_item(self) -> Option<Item> {
|
||||
let item_id = self.item_id?.0.try_into().unwrap();
|
||||
Some(Item {
|
||||
item_id,
|
||||
item_count: self.item_count.0.try_into().unwrap(),
|
||||
})
|
||||
}
|
||||
}
|
||||
impl From<Slot> for Item {
|
||||
fn from(slot: Slot) -> Self {
|
||||
Item {
|
||||
item_count: slot.item_count.0.try_into().unwrap(),
|
||||
item_id: slot.item_id.unwrap().0.try_into().unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user