aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-23 15:28:33 -0500
committermat <github@matdoes.dev>2022-06-23 15:28:33 -0500
commitba399c4440c2d182f55cba7fab068e1118bcc2b7 (patch)
tree20188f93e3fe16b747350ef2b44678b188313c61 /azalea-nbt/src
parent5ca49e680ed8519456dc9a9af84321d4b69dcbb3 (diff)
downloadazalea-drasl-ba399c4440c2d182f55cba7fab068e1118bcc2b7.tar.xz
switch things to use azalea-buf
Diffstat (limited to 'azalea-nbt/src')
-rwxr-xr-xazalea-nbt/src/decode.rs3
-rwxr-xr-xazalea-nbt/src/encode.rs1
-rwxr-xr-xazalea-nbt/src/lib.rs9
3 files changed, 8 insertions, 5 deletions
diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs
index 73cd613e..1c011839 100755
--- a/azalea-nbt/src/decode.rs
+++ b/azalea-nbt/src/decode.rs
@@ -1,5 +1,6 @@
use crate::Error;
use crate::Tag;
+use azalea_buf::McBufReadable;
use byteorder::{ReadBytesExt, BE};
use flate2::read::{GzDecoder, ZlibDecoder};
use std::collections::HashMap;
@@ -139,7 +140,7 @@ impl Tag {
impl McBufReadable for Tag {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- match Tag::read(self) {
+ match Tag::read(buf) {
Ok(r) => Ok(r),
// Err(e) => Err(e.to_string()),
Err(e) => Err(e.to_string()).unwrap(),
diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs
index 17d20270..3763ffd1 100755
--- a/azalea-nbt/src/encode.rs
+++ b/azalea-nbt/src/encode.rs
@@ -1,5 +1,6 @@
use crate::Error;
use crate::Tag;
+use azalea_buf::McBufWritable;
use byteorder::{WriteBytesExt, BE};
use flate2::write::{GzEncoder, ZlibEncoder};
use std::collections::HashMap;
diff --git a/azalea-nbt/src/lib.rs b/azalea-nbt/src/lib.rs
index 8cca1f2b..cb2eb28e 100755
--- a/azalea-nbt/src/lib.rs
+++ b/azalea-nbt/src/lib.rs
@@ -9,23 +9,24 @@ pub use tag::Tag;
#[cfg(test)]
mod tests {
use super::*;
+ use azalea_buf::{McBufReadable, McBufWritable};
use std::{collections::HashMap, io::Cursor};
#[test]
fn mcbuf_nbt() {
let mut buf = Vec::new();
- buf.write_nbt(&Tag::Compound(HashMap::from_iter(vec![(
+ let tag = Tag::Compound(HashMap::from_iter(vec![(
"hello world".to_string(),
Tag::Compound(HashMap::from_iter(vec![(
"name".to_string(),
Tag::String("Bananrama".to_string()),
)])),
- )])))
- .unwrap();
+ )]));
+ tag.write_into(&mut buf).unwrap();
let mut buf = Cursor::new(buf);
- let result = buf.read_nbt().unwrap();
+ let result = Tag::read_into(&mut buf).unwrap();
assert_eq!(
result,
Tag::Compound(HashMap::from_iter(vec![(