diff --git a/protocol-generator/src/main.rs b/protocol-generator/src/main.rs index 0106c14..5fa6f51 100644 --- a/protocol-generator/src/main.rs +++ b/protocol-generator/src/main.rs @@ -17,22 +17,22 @@ pub fn main() { template_engine .register_template_file( - "protocol_imports", - "protocol-generator/templates/protocol_imports.hbs", + "packet_imports", + "protocol-generator/templates/packet_imports.hbs", ) .expect("Failed to register template"); template_engine .register_template_file( - "protocol_enum", - "protocol-generator/templates/protocol_enum.hbs", + "packet_enum", + "protocol-generator/templates/packet_enum.hbs", ) .expect("Failed to register template"); template_engine .register_template_file( - "protocol_structs", - "protocol-generator/templates/protocol_structs.hbs", + "packet_structs", + "protocol-generator/templates/packet_structs.hbs", ) .expect("Failed to register template"); @@ -97,7 +97,7 @@ pub fn main() { #[derive(Serialize)] struct GenerateContext<'a> { - protocol_enum_name: String, + packet_enum_name: String, packets: &'a Vec, } @@ -107,12 +107,12 @@ pub fn generate_rust_file( mut writer: W, ) -> Result<(), TemplateRenderError> { let server_bound_ctx = GenerateContext { - protocol_enum_name: format!("{}{}BoundPacket", &protocol.state, Bound::Server), + packet_enum_name: format!("{}{}BoundPacket", &protocol.state, Bound::Server), packets: &protocol.server_bound_packets, }; let client_bound_ctx = GenerateContext { - protocol_enum_name: format!("{}{}BoundPacket", &protocol.state, Bound::Client), + packet_enum_name: format!("{}{}BoundPacket", &protocol.state, Bound::Client), packets: &protocol.client_bound_packets, }; @@ -126,16 +126,16 @@ pub fn generate_rust_file( imports.extend(protocol.data_type_imports().iter()); template_engine.render_to_write( - "protocol_imports", + "packet_imports", &json!({ "imports": imports }), &mut writer, )?; - template_engine.render_to_write("protocol_enum", &server_bound_ctx, &mut writer)?; - template_engine.render_to_write("protocol_enum", &client_bound_ctx, &mut writer)?; + template_engine.render_to_write("packet_enum", &server_bound_ctx, &mut writer)?; + template_engine.render_to_write("packet_enum", &client_bound_ctx, &mut writer)?; - template_engine.render_to_write("protocol_structs", &server_bound_ctx, &mut writer)?; - template_engine.render_to_write("protocol_structs", &client_bound_ctx, &mut writer)?; + template_engine.render_to_write("packet_structs", &server_bound_ctx, &mut writer)?; + template_engine.render_to_write("packet_structs", &client_bound_ctx, &mut writer)?; Ok(()) } diff --git a/protocol-generator/templates/protocol_enum.hbs b/protocol-generator/templates/packet_enum.hbs similarity index 100% rename from protocol-generator/templates/protocol_enum.hbs rename to protocol-generator/templates/packet_enum.hbs diff --git a/protocol-generator/templates/protocol_imports.hbs b/protocol-generator/templates/packet_imports.hbs similarity index 100% rename from protocol-generator/templates/protocol_imports.hbs rename to protocol-generator/templates/packet_imports.hbs diff --git a/protocol-generator/templates/protocol_structs.hbs b/protocol-generator/templates/packet_structs.hbs similarity index 100% rename from protocol-generator/templates/protocol_structs.hbs rename to protocol-generator/templates/packet_structs.hbs diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs index 5ed10cf..6c92a9c 100644 --- a/protocol/src/lib.rs +++ b/protocol/src/lib.rs @@ -1,7 +1,7 @@ //! This crate implements Minecraft protocol. //! //! Information about protocol can be found at https://wiki.vg/Protocol. -use std::io::{Read, Write}; +use std::io::{Cursor, Read, Write}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use nbt::CompoundTag; @@ -493,6 +493,7 @@ mod rest { } mod uuid_hyp_str { + use std::io::Cursor; use std::io::{Read, Write}; use uuid::Uuid;