aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2024-11-27 19:31:40 -0600
committerGitHub <noreply@github.com>2024-11-27 19:31:40 -0600
commit08958c2278b15ebeac8a964f392ebb792e479b61 (patch)
tree4ae3664cea38d7fd1a8f1e95ed06fac04ffe519e /azalea-world/src
parent139d77d3c2b0922fba5e9d4fa2bd9819d78bd773 (diff)
downloadazalea-drasl-08958c2278b15ebeac8a964f392ebb792e479b61.tar.xz
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
Diffstat (limited to 'azalea-world/src')
-rwxr-xr-xazalea-world/src/chunk_storage.rs26
-rwxr-xr-xazalea-world/src/palette.rs32
2 files changed, 29 insertions, 29 deletions
diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs
index 1709a903..7eb10471 100755
--- a/azalea-world/src/chunk_storage.rs
+++ b/azalea-world/src/chunk_storage.rs
@@ -8,7 +8,7 @@ use std::{
};
use azalea_block::BlockState;
-use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
+use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
use azalea_core::position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos};
use nohash_hasher::IntMap;
use parking_lot::RwLock;
@@ -332,7 +332,7 @@ impl Chunk {
let section_count = dimension_height / SECTION_HEIGHT;
let mut sections = Vec::with_capacity(section_count as usize);
for _ in 0..section_count {
- let section = Section::read_from(buf)?;
+ let section = Section::azalea_read(buf)?;
sections.push(section);
}
@@ -416,10 +416,10 @@ pub fn get_block_state_from_sections(
Some(section.get(chunk_section_pos))
}
-impl McBufWritable for Chunk {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+impl AzaleaWrite for Chunk {
+ fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
for section in &self.sections {
- section.write_into(buf)?;
+ section.azalea_write(buf)?;
}
Ok(())
}
@@ -437,9 +437,9 @@ impl Debug for PartialChunkStorage {
}
}
-impl McBufReadable for Section {
- fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let block_count = u16::read_from(buf)?;
+impl AzaleaRead for Section {
+ fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
+ let block_count = u16::azalea_read(buf)?;
// this is commented out because the vanilla server is wrong
// assert!(
@@ -467,11 +467,11 @@ impl McBufReadable for Section {
}
}
-impl McBufWritable for Section {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- self.block_count.write_into(buf)?;
- self.states.write_into(buf)?;
- self.biomes.write_into(buf)?;
+impl AzaleaWrite for Section {
+ fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ self.block_count.azalea_write(buf)?;
+ self.states.azalea_write(buf)?;
+ self.biomes.azalea_write(buf)?;
Ok(())
}
}
diff --git a/azalea-world/src/palette.rs b/azalea-world/src/palette.rs
index 27e017c4..24dbe47a 100755
--- a/azalea-world/src/palette.rs
+++ b/azalea-world/src/palette.rs
@@ -1,6 +1,6 @@
use std::io::{Cursor, Write};
-use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
+use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_core::math;
use tracing::warn;
@@ -44,11 +44,11 @@ impl PalettedContainer {
buf: &mut Cursor<&[u8]>,
container_type: &'static PalettedContainerKind,
) -> Result<Self, BufReadError> {
- let server_bits_per_entry = u8::read_from(buf)?;
+ let server_bits_per_entry = u8::azalea_read(buf)?;
let palette_type = PaletteKind::from_bits_and_type(server_bits_per_entry, container_type);
let palette = palette_type.read(buf)?;
let size = container_type.size();
- let data = Vec::<u64>::read_from(buf)?;
+ let data = Vec::<u64>::azalea_read(buf)?;
// we can only trust the bits per entry that we're sent if there's enough data
// that it'd be global. if it's not global, then we have to calculate it
@@ -224,11 +224,11 @@ impl PalettedContainer {
}
}
-impl McBufWritable for PalettedContainer {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- self.bits_per_entry.write_into(buf)?;
- self.palette.write_into(buf)?;
- self.storage.data.write_into(buf)?;
+impl AzaleaWrite for PalettedContainer {
+ fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ self.bits_per_entry.azalea_write(buf)?;
+ self.palette.azalea_write(buf)?;
+ self.storage.data.azalea_write(buf)?;
Ok(())
}
}
@@ -264,17 +264,17 @@ impl Palette {
}
}
-impl McBufWritable for Palette {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+impl AzaleaWrite for Palette {
+ fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
match self {
Palette::SingleValue(value) => {
- value.var_write_into(buf)?;
+ value.azalea_write_var(buf)?;
}
Palette::Linear(values) => {
- values.var_write_into(buf)?;
+ values.azalea_write_var(buf)?;
}
Palette::Hashmap(values) => {
- values.var_write_into(buf)?;
+ values.azalea_write_var(buf)?;
}
Palette::Global => {}
}
@@ -301,9 +301,9 @@ impl PaletteKind {
pub fn read(&self, buf: &mut Cursor<&[u8]>) -> Result<Palette, BufReadError> {
Ok(match self {
- PaletteKind::SingleValue => Palette::SingleValue(u32::var_read_from(buf)?),
- PaletteKind::Linear => Palette::Linear(Vec::<u32>::var_read_from(buf)?),
- PaletteKind::Hashmap => Palette::Hashmap(Vec::<u32>::var_read_from(buf)?),
+ PaletteKind::SingleValue => Palette::SingleValue(u32::azalea_read_var(buf)?),
+ PaletteKind::Linear => Palette::Linear(Vec::<u32>::azalea_read_var(buf)?),
+ PaletteKind::Hashmap => Palette::Hashmap(Vec::<u32>::azalea_read_var(buf)?),
PaletteKind::Global => Palette::Global,
})
}