azalea_protocol/packets/game/
c_map_item_data.rs1use std::io::{self, Cursor, Write};
2
3use azalea_buf::AzBuf;
4use azalea_chat::FormattedText;
5use azalea_protocol_macros::ClientboundGamePacket;
6
7#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
8pub struct ClientboundMapItemData {
9 #[var]
10 pub map_id: u32,
11 pub scale: u8,
12 pub locked: bool,
13 pub decorations: Option<Vec<MapDecoration>>,
14 pub color_patch: OptionalMapPatch,
15}
16
17#[derive(AzBuf, Clone, Debug, PartialEq)]
18pub struct MapDecoration {
19 pub decoration_type: DecorationType,
20 pub x: i8,
21 pub y: i8,
22 pub rot: i8,
25 pub name: Option<FormattedText>,
26}
27
28#[derive(Clone, Debug, PartialEq)]
29pub struct OptionalMapPatch(pub Option<MapPatch>);
30
31impl AzBuf for OptionalMapPatch {
32 fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
33 let pos = buf.position();
34 Ok(Self(if u8::azalea_read(buf)? == 0 {
35 None
36 } else {
37 buf.set_position(pos);
38 Some(MapPatch::azalea_read(buf)?)
39 }))
40 }
41 fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
42 match &self.0 {
43 None => 0u8.azalea_write(buf),
44 Some(m) => m.azalea_write(buf),
45 }
46 }
47}
48
49#[derive(AzBuf, Clone, Debug, PartialEq)]
50pub struct MapPatch {
51 pub width: u8,
52 pub height: u8,
53 pub start_x: u8,
54 pub start_y: u8,
55 pub map_colors: Vec<u8>,
56}
57
58#[derive(AzBuf, Clone, Copy, Debug, PartialEq)]
59pub enum DecorationType {
60 Player,
61 Frame,
62 RedMarker,
63 BlueMarker,
64 TargetX,
65 TargetPoint,
66 PlayerOffMap,
67 PlayerOffLimits,
68 Mansion,
69 Monument,
70 BannerWhite,
71 BannerOrange,
72 BannerMagenta,
73 BannerLightBlue,
74 BannerYellow,
75 BannerLime,
76 BannerPink,
77 BannerGray,
78 BannerLightGray,
79 BannerCyan,
80 BannerPurple,
81 BannerBlue,
82 BannerBrown,
83 BannerGreen,
84 BannerRed,
85 BannerBlack,
86 RedX,
87}