Fix tests and rename to packet templates
This commit is contained in:
parent
fca5351977
commit
f1c602092c
@ -17,22 +17,22 @@ pub fn main() {
|
|||||||
|
|
||||||
template_engine
|
template_engine
|
||||||
.register_template_file(
|
.register_template_file(
|
||||||
"protocol_imports",
|
"packet_imports",
|
||||||
"protocol-generator/templates/protocol_imports.hbs",
|
"protocol-generator/templates/packet_imports.hbs",
|
||||||
)
|
)
|
||||||
.expect("Failed to register template");
|
.expect("Failed to register template");
|
||||||
|
|
||||||
template_engine
|
template_engine
|
||||||
.register_template_file(
|
.register_template_file(
|
||||||
"protocol_enum",
|
"packet_enum",
|
||||||
"protocol-generator/templates/protocol_enum.hbs",
|
"protocol-generator/templates/packet_enum.hbs",
|
||||||
)
|
)
|
||||||
.expect("Failed to register template");
|
.expect("Failed to register template");
|
||||||
|
|
||||||
template_engine
|
template_engine
|
||||||
.register_template_file(
|
.register_template_file(
|
||||||
"protocol_structs",
|
"packet_structs",
|
||||||
"protocol-generator/templates/protocol_structs.hbs",
|
"protocol-generator/templates/packet_structs.hbs",
|
||||||
)
|
)
|
||||||
.expect("Failed to register template");
|
.expect("Failed to register template");
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ pub fn main() {
|
|||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct GenerateContext<'a> {
|
struct GenerateContext<'a> {
|
||||||
protocol_enum_name: String,
|
packet_enum_name: String,
|
||||||
packets: &'a Vec<Packet>,
|
packets: &'a Vec<Packet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,12 +107,12 @@ pub fn generate_rust_file<W: Write>(
|
|||||||
mut writer: W,
|
mut writer: W,
|
||||||
) -> Result<(), TemplateRenderError> {
|
) -> Result<(), TemplateRenderError> {
|
||||||
let server_bound_ctx = GenerateContext {
|
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,
|
packets: &protocol.server_bound_packets,
|
||||||
};
|
};
|
||||||
|
|
||||||
let client_bound_ctx = GenerateContext {
|
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,
|
packets: &protocol.client_bound_packets,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,16 +126,16 @@ pub fn generate_rust_file<W: Write>(
|
|||||||
imports.extend(protocol.data_type_imports().iter());
|
imports.extend(protocol.data_type_imports().iter());
|
||||||
|
|
||||||
template_engine.render_to_write(
|
template_engine.render_to_write(
|
||||||
"protocol_imports",
|
"packet_imports",
|
||||||
&json!({ "imports": imports }),
|
&json!({ "imports": imports }),
|
||||||
&mut writer,
|
&mut writer,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
template_engine.render_to_write("protocol_enum", &server_bound_ctx, &mut writer)?;
|
template_engine.render_to_write("packet_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", &client_bound_ctx, &mut writer)?;
|
||||||
|
|
||||||
template_engine.render_to_write("protocol_structs", &server_bound_ctx, &mut writer)?;
|
template_engine.render_to_write("packet_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", &client_bound_ctx, &mut writer)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! This crate implements Minecraft protocol.
|
//! This crate implements Minecraft protocol.
|
||||||
//!
|
//!
|
||||||
//! Information about protocol can be found at https://wiki.vg/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 byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use nbt::CompoundTag;
|
use nbt::CompoundTag;
|
||||||
@ -493,6 +493,7 @@ mod rest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod uuid_hyp_str {
|
mod uuid_hyp_str {
|
||||||
|
use std::io::Cursor;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user