From 08958c2278b15ebeac8a964f392ebb792e479b61 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Wed, 27 Nov 2024 19:31:40 -0600 Subject: Refactor azalea-protocol (#190) * start updating to 1.21.4 * fix block codegen and stop using block data from burger * rename packet related modules and structs to be simpler * ItemSlot -> ItemStack for more consistency with mojmap * .get() -> .into_packet() * simplify declare_state_packets by removing packet ids * rename read_from and write_into to azalea_read and azalea_write * rename McBufReadable and McBufWritable to AzaleaRead and AzaleaWrite * McBuf -> AzBuf * remove most uses of into_variant * update codegen and use resourcelocation names for packets * implement #[limit(i)] attribute for AzBuf derive macro * fixes for 1.21.4 * fix examples * update some physics code and fix ChatType * remove unused imports in codegen * re-add some things to migrate.py and update +mc version numbers automatically * downgrade to 1.21.3 lol --- azalea-brigadier/src/suggestion/mod.rs | 10 ++++----- azalea-brigadier/src/suggestion/suggestions.rs | 28 ++++++++++++-------------- 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'azalea-brigadier/src') diff --git a/azalea-brigadier/src/suggestion/mod.rs b/azalea-brigadier/src/suggestion/mod.rs index 753b1bc8..a31b6837 100755 --- a/azalea-brigadier/src/suggestion/mod.rs +++ b/azalea-brigadier/src/suggestion/mod.rs @@ -9,7 +9,7 @@ use std::{ }; #[cfg(feature = "azalea-buf")] -use azalea_buf::McBufWritable; +use azalea_buf::AzaleaWrite; #[cfg(feature = "azalea-buf")] use azalea_chat::FormattedText; pub use suggestions::Suggestions; @@ -137,13 +137,13 @@ impl PartialOrd for SuggestionValue { } #[cfg(feature = "azalea-buf")] -impl McBufWritable for Suggestion { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - self.value.to_string().write_into(buf)?; +impl AzaleaWrite for Suggestion { + fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + self.value.to_string().azalea_write(buf)?; self.tooltip .clone() .map(FormattedText::from) - .write_into(buf)?; + .azalea_write(buf)?; Ok(()) } } diff --git a/azalea-brigadier/src/suggestion/suggestions.rs b/azalea-brigadier/src/suggestion/suggestions.rs index 5941aa7d..60eaa111 100755 --- a/azalea-brigadier/src/suggestion/suggestions.rs +++ b/azalea-brigadier/src/suggestion/suggestions.rs @@ -3,9 +3,7 @@ use std::io::{Cursor, Write}; use std::{collections::HashSet, hash::Hash}; #[cfg(feature = "azalea-buf")] -use azalea_buf::{ - BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, -}; +use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError}; #[cfg(feature = "azalea-buf")] use azalea_chat::FormattedText; @@ -79,21 +77,21 @@ impl Suggestions { } #[cfg(feature = "azalea-buf")] -impl McBufReadable for Suggestions { - fn read_from(buf: &mut Cursor<&[u8]>) -> Result { - #[derive(McBuf)] +impl AzaleaRead for Suggestions { + fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { + #[derive(AzBuf)] struct StandaloneSuggestion { pub text: String, pub tooltip: Option, } - let start = u32::var_read_from(buf)? as usize; - let length = u32::var_read_from(buf)? as usize; + let start = u32::azalea_read_var(buf)? as usize; + let length = u32::azalea_read_var(buf)? as usize; let range = StringRange::between(start, start + length); // the range of a Suggestion depends on the Suggestions containing it, - // so we can't just `impl McBufReadable for Suggestion` - let mut suggestions = Vec::::read_from(buf)? + // so we can't just `impl AzaleaRead for Suggestion` + let mut suggestions = Vec::::azalea_read(buf)? .into_iter() .map(|s| Suggestion { value: SuggestionValue::Text(s.text), @@ -108,11 +106,11 @@ impl McBufReadable for Suggestions { } #[cfg(feature = "azalea-buf")] -impl McBufWritable for Suggestions { - fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - (self.range.start() as u32).var_write_into(buf)?; - (self.range.length() as u32).var_write_into(buf)?; - self.suggestions.write_into(buf)?; +impl AzaleaWrite for Suggestions { + fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + (self.range.start() as u32).azalea_write_var(buf)?; + (self.range.length() as u32).azalea_write_var(buf)?; + self.suggestions.azalea_write(buf)?; Ok(()) } } -- cgit v1.2.3