-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Bryntet/master
Add packets CCloseContainer, CSetContainerProperty and SCloseContainer
- Loading branch information
Showing
9 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use num_derive::ToPrimitive; | ||
use num_traits::ToPrimitive; | ||
|
||
pub trait WindowPropertyTrait { | ||
fn to_id(self) -> i16; | ||
} | ||
|
||
impl<T: ToPrimitive> WindowPropertyTrait for T { | ||
fn to_id(self) -> i16 { | ||
self.to_i16().unwrap() | ||
} | ||
} | ||
|
||
pub struct WindowProperty<T: WindowPropertyTrait> { | ||
window_property: T, | ||
value: i16, | ||
} | ||
|
||
impl<T: WindowPropertyTrait> WindowProperty<T> { | ||
pub fn new(window_property: T, value: i16) -> Self { | ||
Self { | ||
window_property, | ||
value, | ||
} | ||
} | ||
|
||
pub fn into_tuple(self) -> (i16, i16) { | ||
(self.window_property.to_id(), self.value) | ||
} | ||
} | ||
#[derive(ToPrimitive)] | ||
pub enum Furnace { | ||
FireIcon, | ||
MaximumFuelBurnTime, | ||
ProgressArrow, | ||
MaximumProgress, | ||
} | ||
|
||
pub enum EnchantmentTable { | ||
LevelRequirement { slot: u8 }, | ||
EnchantmentSeed, | ||
EnchantmentId { slot: u8 }, | ||
EnchantmentLevel { slot: u8 }, | ||
} | ||
|
||
impl WindowPropertyTrait for EnchantmentTable { | ||
fn to_id(self) -> i16 { | ||
use EnchantmentTable::*; | ||
|
||
(match self { | ||
LevelRequirement { slot } => slot, | ||
EnchantmentSeed => 3, | ||
EnchantmentId { slot } => 4 + slot, | ||
EnchantmentLevel { slot } => 7 + slot, | ||
}) as i16 | ||
} | ||
} | ||
#[derive(ToPrimitive)] | ||
pub enum Beacon { | ||
PowerLevel, | ||
FirstPotionEffect, | ||
SecondPotionEffect, | ||
} | ||
|
||
#[derive(ToPrimitive)] | ||
pub enum Anvil { | ||
RepairCost, | ||
} | ||
|
||
#[derive(ToPrimitive)] | ||
pub enum BrewingStand { | ||
BrewTime, | ||
FuelTime, | ||
} | ||
|
||
#[derive(ToPrimitive)] | ||
pub enum Stonecutter { | ||
SelectedRecipe, | ||
} | ||
|
||
#[derive(ToPrimitive)] | ||
pub enum Loom { | ||
SelectedPattern, | ||
} | ||
|
||
#[derive(ToPrimitive)] | ||
pub enum Lectern { | ||
PageNumber, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use pumpkin_macros::packet; | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize)] | ||
#[packet(0x12)] | ||
pub struct CCloseContainer { | ||
window_id: u8, | ||
} | ||
|
||
impl CCloseContainer { | ||
pub const fn new(window_id: u8) -> Self { | ||
Self { window_id } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
pumpkin-protocol/src/client/play/c_set_container_property.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use pumpkin_macros::packet; | ||
use serde::Serialize; | ||
#[derive(Serialize)] | ||
#[packet(0x14)] | ||
pub struct CSetContainerProperty { | ||
window_id: u8, | ||
property: i16, | ||
value: i16, | ||
} | ||
|
||
impl CSetContainerProperty { | ||
pub const fn new(window_id: u8, property: i16, value: i16) -> Self { | ||
Self { | ||
window_id, | ||
property, | ||
value, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use pumpkin_macros::packet; | ||
use serde::Deserialize; | ||
|
||
#[derive(Deserialize)] | ||
#[packet(0x0F)] | ||
pub struct SCloseContainer { | ||
pub window_id: u8, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters