]> git.lizzy.rs Git - mt_net.git/blob - src/to_clt.rs
Implement NodeMeta and add Inventory stub
[mt_net.git] / src / to_clt.rs
1 use super::*;
2
3 #[mt_derive(to = "clt")]
4 pub struct Color {
5     pub a: u8,
6     pub r: u8,
7     pub g: u8,
8     pub b: u8,
9 }
10
11 #[mt_derive(to = "clt", repr = "u8")]
12 pub enum ModChanSig {
13     JoinOk = 0,
14     JoinFail,
15     LeaveOk,
16     LeaveFail,
17     NotRegistered,
18     SetState,
19 }
20
21 #[mt_derive(to = "clt", repr = "u32", enumset)]
22 pub enum AuthMethod {
23     LegacyPasswd,
24     Srp,
25     FirstSrp,
26 }
27
28 #[mt_derive(to = "clt", repr = "u64", enumset)]
29 pub enum CsmRestrictionFlag {
30     NoCsms,
31     NoChatMsgs,
32     NoItemDefs,
33     NoNodeDefs,
34     LimitMapRange,
35     NoPlayerList,
36 }
37
38 #[mt_derive(to = "clt", repr = "u8")]
39 pub enum ChatMsgType {
40     Raw = 0,
41     Normal,
42     Announce,
43     System,
44 }
45
46 #[mt_derive(to = "clt", repr = "u8")]
47 pub enum PlayerListUpdateType {
48     Init = 0,
49     Add,
50     Remove,
51 }
52
53 mod hud;
54 mod inv;
55 mod kick;
56 mod map;
57 mod media;
58 mod obj;
59 mod sky;
60
61 pub use hud::*;
62 pub use inv::*;
63 pub use kick::*;
64 pub use map::*;
65 pub use media::*;
66 pub use obj::*;
67 pub use sky::*;
68
69 #[mt_derive(to = "clt", repr = "u16", tag = "type", content = "data")]
70 pub enum ToCltPkt {
71     Hello {
72         serialize_version: u8,
73         #[mt(const_before = "1u16")] // compression
74         proto_version: u16,
75         auth_methods: EnumSet<AuthMethod>,
76         username: String,
77     } = 2,
78     AcceptAuth {
79         player_pos: [f32; 3],
80         map_seed: u64,
81         send_interval: f32,
82         sudo_auth_methods: EnumSet<AuthMethod>,
83     } = 3,
84     AcceptSudoMode {
85         #[mt(const_after = "[0u8; 15]")]
86         sudo_auth_methods: EnumSet<AuthMethod>,
87     } = 4,
88     DenySudoMode = 5,
89     Kick(KickReason) = 10,
90     BlockData {
91         pos: [i16; 3],
92         #[mt(zstd)]
93         block: Box<MapBlock>,
94     } = 32,
95     AddNode {
96         pos: [i16; 3],
97         param0: u16,
98         param1: u8,
99         param2: u8,
100         keep_meta: bool,
101     } = 33,
102     RemoveNode {
103         pos: [i16; 3],
104     } = 34,
105     Inv {
106         #[mt(len = "()")]
107         inv: String,
108     } = 39,
109     TimeOfDay {
110         time: u16,
111         speed: f32,
112     } = 41,
113     CsmRestrictionFlags {
114         flags: EnumSet<CsmRestrictionFlag>,
115         map_range: u32,
116     } = 42,
117     AddPlayerVelocity {
118         vel: [f32; 3],
119     } = 43,
120     MediaPush {
121         raw_hash: String,
122         filename: String,
123         callback_token: u32,
124         should_cache: bool,
125     } = 44,
126     ChatMsg {
127         #[mt(const_before = "1u8")]
128         msg_type: ChatMsgType,
129         #[mt(len = "Utf16")]
130         sender: String,
131         #[mt(len = "Utf16")]
132         text: String,
133         timestamp: i64, // unix time
134     } = 47,
135     ObjRemoveAdd {
136         remove: Vec<u16>,
137         add: Vec<ObjAdd>,
138     } = 49,
139     ObjMsgs {
140         #[mt(len = "()")]
141         msgs: Vec<ObjIdMsg>,
142     } = 50,
143     Hp {
144         hp: u16,
145         #[mt(default)]
146         damage_effect: bool,
147     } = 51,
148     MovePlayer {
149         pos: [f32; 3],
150         pitch: f32,
151         yaw: f32,
152     } = 52,
153     LegacyKick {
154         #[mt(len = "Utf16")]
155         reason: String,
156     } = 53,
157     Fov {
158         fov: f32,
159         multiplier: bool,
160         transition_time: f32,
161     } = 54,
162     DeathScreen {
163         point_cam: bool,
164         point_at: [f32; 3],
165     } = 55,
166     Media {
167         n: u16,
168         i: u16,
169         #[mt(len = "(u32, (DefCfg, u32))")]
170         files: HashMap<String, Vec<u8>>, // name -> payload
171     } = 56,
172     #[mt(size = "u32", zlib)]
173     NodeDefs {
174         #[mt(const_before = "1u8")] // version
175         defs: Vec<NodeDef>,
176     } = 58,
177     AnnounceMedia {
178         files: HashMap<String, String>, // name -> base64 sha1 hash
179         url: String,
180     } = 60,
181     #[mt(size = "u32", zlib)]
182     ItemDefs {
183         #[mt(const_before = "0u8")] // version
184         defs: Vec<ItemDef>,
185         aliases: HashMap<String, String>,
186     } = 61,
187     PlaySound {
188         id: u32,
189         name: String,
190         gain: f32,
191         src_type: SoundSrcType,
192         pos: [f32; 3],
193         src_obj_id: u16,
194         #[serde(rename = "loop")]
195         sound_loop: bool,
196         fade: f32,
197         pitch: f32,
198         ephermeral: bool,
199     } = 63,
200     StopSound {
201         id: u32,
202     } = 64,
203     Privs {
204         privs: HashSet<String>,
205     } = 65,
206     InvFormspec {
207         #[mt(size = "u32")]
208         formspec: String,
209     } = 66,
210     DetachedInv {
211         name: String,
212         keep: bool,
213         len: u16,
214         #[mt(len = "()")]
215         inv: String,
216     } = 67,
217     ShowFormspec {
218         #[mt(len = "u32")]
219         formspec: String,
220         formname: String,
221     } = 68,
222     Movement {
223         default_accel: f32,
224         air_accel: f32,
225         fast_accel: f32,
226         walk_speed: f32,
227         crouch_speed: f32,
228         fast_speed: f32,
229         climb_speed: f32,
230         jump_speed: f32,
231         fluidity: f32,
232         smoothing: f32,
233         sink: f32,
234         gravity: f32,
235     } = 69,
236     SpawnParticle {
237         pos: [f32; 3],
238         vel: [f32; 3],
239         acc: [f32; 3],
240         expiration_time: f32,
241         size: f32,
242         collide: bool,
243         #[mt(len = "u32")]
244         texture: String,
245         vertical: bool,
246         collision_rm: bool,
247         anim_params: TileAnim,
248         glow: u8,
249         obj_collision: bool,
250         node_param0: u16,
251         node_param2: u8,
252         node_tile: u8,
253     } = 70,
254     AddParticleSpawner {
255         amount: u16,
256         duration: f32,
257         pos: [[f32; 3]; 2],
258         vel: [[f32; 3]; 2],
259         acc: [[f32; 3]; 2],
260         expiration_time: [f32; 2],
261         size: [f32; 2],
262         collide: bool,
263         #[mt(len = "u32")]
264         texture: String,
265         id: u32,
266         vertical: bool,
267         collision_rm: bool,
268         attached_obj_id: u16,
269         anim_params: TileAnim,
270         glow: u8,
271         obj_collision: bool,
272         node_param0: u16,
273         node_param2: u8,
274         node_tile: u8,
275     } = 71,
276     AddHud {
277         id: u32,
278         hud: HudElement,
279     } = 73,
280     RemoveHud {
281         id: u32,
282     } = 74,
283     ChangeHud {
284         id: u32,
285         change: HudChange,
286     } = 75,
287     HudFlags {
288         flags: EnumSet<HudFlag>,
289         mask: EnumSet<HudFlag>,
290     } = 76,
291     SetHotbarParam(HotbarParam) = 77,
292     Breath {
293         breath: u16,
294     } = 78,
295     SkyParams(SkyParams) = 79,
296     OverrideDayNightRatio {
297         #[serde(rename = "override")]
298         ratio_override: bool,
299         ratio: u16,
300     } = 80,
301     LocalPlayerAnim {
302         idle: [i32; 2],
303         walk: [i32; 2],
304         dig: [i32; 2],
305         walk_dig: [i32; 2],
306         speed: f32,
307     } = 81,
308     EyeOffset {
309         first: [f32; 3],
310         third: [f32; 3],
311     } = 82,
312     RemoveParticleSpawner {
313         id: u32,
314     } = 83,
315     CloudParams(CloudParams) = 84,
316     FadeSound {
317         id: u32,
318         step: f32,
319         gain: f32,
320     } = 85,
321     UpdatePlayerList {
322         update_type: PlayerListUpdateType,
323         players: HashSet<String>,
324     } = 86,
325     ModChanMsg {
326         channel: String,
327         sender: String,
328         msg: String,
329     } = 87,
330     ModChanSig {
331         signal: ModChanSig,
332         channel: String,
333     } = 88,
334     NodeMetasChanged {
335         #[mt(size = "u32", zlib)]
336         #[mt(len = "NodeMetasLen")]
337         changed: HashMap<[i16; 3], NodeMeta>,
338     } = 89,
339     SunParams(SunParams) = 90,
340     MoonParams(MoonParams) = 91,
341     StarParams(StarParams) = 92,
342     SrpBytesSaltB {
343         salt: Vec<u8>,
344         b: Vec<u8>,
345     } = 96,
346     FormspecPrepend {
347         prepend: String,
348     } = 97,
349     MinimapModes(MinimapModesPkt) = 98,
350 }