Skip to content

Commit

Permalink
add ContainerClosePacket
Browse files Browse the repository at this point in the history
  • Loading branch information
banchen19 committed Aug 9, 2024
1 parent 822c9ab commit 7aebbac
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
9 changes: 5 additions & 4 deletions crates/proto/src/gamepacket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::packets::animate::AnimatePacket;
use crate::packets::chunk_radius_updated::ChunkRadiusUpdatedPacket;
use crate::packets::client_cache_status::ClientCacheStatusPacket;
use crate::packets::command_request_packet::CommandRequestPacket;
use crate::packets::container_close_packet::ContainerClosePacket;
use crate::packets::correct_player_move_prediction_packet::CorrectPlayerMovePredictionPacket;
use crate::packets::disconnect::DisconnectPacket;
use crate::packets::emote_list::EmoteListPacket;
Expand Down Expand Up @@ -86,7 +87,7 @@ pub enum GamePacket {
Animate(AnimatePacket),
Respawn(),
ContainerOpen(),
ContainerClose(),
ContainerClose(ContainerClosePacket),
PlayerHotbar(),
InventoryContent(),
InventorySlot(),
Expand Down Expand Up @@ -535,8 +536,8 @@ impl GamePacket {
GamePacket::ContainerOpen() => {
unimplemented!()
}
GamePacket::ContainerClose() => {
unimplemented!()
GamePacket::ContainerClose(pk) => {
ser_packet!(stream, GamePacket::ContainerCloseID, pk)
}
GamePacket::PlayerHotbar() => {
unimplemented!()
Expand Down Expand Up @@ -1007,7 +1008,7 @@ impl GamePacket {
unimplemented!()
}
GamePacket::ContainerCloseID => {
unimplemented!()
GamePacket::ContainerClose(de_packet!(stream, ContainerClosePacket))
}
GamePacket::PlayerHotbarID => {
unimplemented!()
Expand Down
10 changes: 10 additions & 0 deletions crates/proto/src/packets/container_close_packet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use bedrockrs_proto_derive::ProtoCodec;

use crate::types::container_type::ContainerType;

#[derive(ProtoCodec, Debug, Clone)]
pub struct ContainerClosePacket {
container_id: u8,
container_type: ContainerType,
server_initiated_close: bool,
}
1 change: 1 addition & 0 deletions crates/proto/src/packets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod animate;
pub mod chunk_radius_updated;
pub mod client_cache_status;
pub mod command_request_packet;
pub mod container_close_packet;
pub mod correct_player_move_prediction_packet;
pub mod disconnect;
pub mod emote_list;
Expand Down
6 changes: 3 additions & 3 deletions crates/proto/src/types/command_origin_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum CommandOriginType {

#[derive(ProtoCodec, Debug, Clone)]
pub struct CommandOriginData {
command_type: CommandOriginType,
command_uuid: Uuid,
request_id: String,
pub command_type: CommandOriginType,
pub command_uuid: Uuid,
pub request_id: String,
}
46 changes: 46 additions & 0 deletions crates/proto/src/types/container_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use bedrockrs_core::int::BE;
use bedrockrs_proto_derive::ProtoCodec;

#[derive(ProtoCodec, Debug, Copy, Clone, Eq, PartialEq)]
#[enum_repr(BE::<i32>)]
pub enum ContainerType {
NONE = -9,
INVENTORY = -1,
CONTAINER = 0,
WORKBENCH = 1,
FURNACE = 2,
ENCHANTMENT = 3,
BREWING_STAND = 4,
ANVIL = 5,
DISPENSER = 6,
DROPPER = 7,
HOPPER = 8,
CAULDRON = 9,
MINECART_CHEST = 10,
MINECART_HOPPER = 11,
HORSE = 12,
BEACON = 13,
STRUCTURE_EDITOR = 14,
TRADE = 15,
COMMAND_BLOCK = 16,
JUKEBOX = 17,
ARMOR = 18,
HAND = 19,
COMPOUND_CREATOR = 20,
ELEMENT_CONSTRUCTOR = 21,
MATERIAL_REDUCER = 22,
LAB_TABLE = 23,
LOOM = 24,
LECTERN = 25,
GRINDSTONE = 26,
BLAST_FURNACE = 27,
SMOKER = 28,
STONECUTTER = 29,
CARTOGRAPHY = 30,
HUD = 31,
JIGSAW_EDITOR = 32,
SMITHING_TABLE = 33,
CHEST_BOAT = 34,
DECORATED_POT = 35,
CRAFTER = 36,
}
1 change: 1 addition & 0 deletions crates/proto/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod chat_restriction_level;
pub mod chunk_pos;
pub mod command_origin_data;
pub mod connection_request;
pub mod container_type;
pub mod dataitem;
pub mod disconnect_reason;
pub mod edu_shared_uri_resource;
Expand Down

0 comments on commit 7aebbac

Please sign in to comment.