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