aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xazalea-core/src/slot.rs4
-rwxr-xr-xazalea-nbt/README.md10
-rwxr-xr-xazalea-nbt/benches/compare.rs4
-rwxr-xr-xazalea-nbt/benches/nbt.rs6
-rwxr-xr-xazalea-nbt/src/decode.rs54
-rwxr-xr-xazalea-nbt/src/encode.rs62
-rwxr-xr-xazalea-nbt/src/lib.rs16
-rwxr-xr-xazalea-nbt/src/tag.rs18
-rwxr-xr-xazalea-nbt/tests/tests.rs30
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_login_packet.rs40
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_tag_query_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs2
-rwxr-xr-xazalea-world/src/entity/data.rs2
-rw-r--r--azalea-world/src/entity/metadata.rs8
-rw-r--r--codegen/lib/code/entity.py4
-rwxr-xr-xcodegen/lib/code/utils.py2
19 files changed, 136 insertions, 136 deletions
diff --git a/azalea-core/src/slot.rs b/azalea-core/src/slot.rs
index 4406e08d..22961437 100755
--- a/azalea-core/src/slot.rs
+++ b/azalea-core/src/slot.rs
@@ -1,7 +1,7 @@
// TODO: have an azalea-inventory or azalea-container crate and put this there
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
-use azalea_nbt::Tag;
+use azalea_nbt::Nbt;
use std::io::{Cursor, Write};
#[derive(Debug, Clone, Default)]
@@ -16,7 +16,7 @@ pub struct SlotData {
#[var]
pub id: u32,
pub count: u8,
- pub nbt: Tag,
+ pub nbt: Nbt,
}
impl McBufReadable for Slot {
diff --git a/azalea-nbt/README.md b/azalea-nbt/README.md
index 97da90cc..c4d25c46 100755
--- a/azalea-nbt/README.md
+++ b/azalea-nbt/README.md
@@ -5,18 +5,18 @@ A fast NBT serializer and deserializer.
# Examples
```
-use azalea_nbt::{Tag, NbtCompound};
+use azalea_nbt::{Nbt, NbtCompound};
use std::io::Cursor;
let buf = include_bytes!("../tests/hello_world.nbt");
-let tag = Tag::read(&mut Cursor::new(&buf[..])).unwrap();
+let tag = Nbt::read(&mut Cursor::new(&buf[..])).unwrap();
assert_eq!(
tag,
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"hello world".into(),
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"name".into(),
- Tag::String("Bananrama".into()),
+ Nbt::String("Bananrama".into()),
)]))
)]))
);
diff --git a/azalea-nbt/benches/compare.rs b/azalea-nbt/benches/compare.rs
index 91fba9f5..1634b45b 100755
--- a/azalea-nbt/benches/compare.rs
+++ b/azalea-nbt/benches/compare.rs
@@ -25,7 +25,7 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
group.bench_function("azalea_parse", |b| {
b.iter(|| {
let input = black_box(input);
- let nbt = azalea_nbt::Tag::read(&mut Cursor::new(&input)).unwrap();
+ let nbt = azalea_nbt::Nbt::read(&mut Cursor::new(&input)).unwrap();
black_box(nbt);
})
});
@@ -48,7 +48,7 @@ pub fn bench_read_file(filename: &str, c: &mut Criterion) {
// // writing
- let nbt = azalea_nbt::Tag::read_from(&mut Cursor::new(input)).unwrap();
+ let nbt = azalea_nbt::Nbt::read_from(&mut Cursor::new(input)).unwrap();
group.bench_function("azalea_write", |b| {
b.iter(|| {
let nbt = black_box(&nbt);
diff --git a/azalea-nbt/benches/nbt.rs b/azalea-nbt/benches/nbt.rs
index cfa05a9d..c74f9fae 100755
--- a/azalea-nbt/benches/nbt.rs
+++ b/azalea-nbt/benches/nbt.rs
@@ -1,4 +1,4 @@
-use azalea_nbt::Tag;
+use azalea_nbt::Nbt;
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use flate2::read::GzDecoder;
use std::{
@@ -19,7 +19,7 @@ fn bench_file(filename: &str, c: &mut Criterion) {
let mut decoded_src_stream = Cursor::new(&decoded_src[..]);
- let nbt = Tag::read(&mut decoded_src_stream).unwrap();
+ let nbt = Nbt::read(&mut decoded_src_stream).unwrap();
decoded_src_stream.set_position(0);
let mut group = c.benchmark_group(filename);
@@ -28,7 +28,7 @@ fn bench_file(filename: &str, c: &mut Criterion) {
group.bench_function("Decode", |b| {
b.iter(|| {
- black_box(Tag::read(&mut decoded_src_stream).unwrap());
+ black_box(Nbt::read(&mut decoded_src_stream).unwrap());
decoded_src_stream.set_position(0);
})
});
diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs
index e2e9c7c9..5421e1c5 100755
--- a/azalea-nbt/src/decode.rs
+++ b/azalea-nbt/src/decode.rs
@@ -169,7 +169,7 @@ fn read_compound(stream: &mut Cursor<&[u8]>) -> Result<NbtCompound, Error> {
break;
}
let name = read_string(stream)?;
- let tag = Tag::read_known(stream, tag_id)?;
+ let tag = Nbt::read_known(stream, tag_id)?;
map.insert(name, tag);
}
Ok(map)
@@ -201,36 +201,36 @@ fn read_long_array(stream: &mut Cursor<&[u8]>) -> Result<NbtLongArray, Error> {
Ok(longs)
}
-impl Tag {
+impl Nbt {
/// Read the NBT data when you already know the ID of the tag. You usually
- /// want [`Tag::read`] if you're reading an NBT file.
+ /// want [`Nbt::read`] if you're reading an NBT file.
#[inline]
- fn read_known(stream: &mut Cursor<&[u8]>, id: u8) -> Result<Tag, Error> {
+ fn read_known(stream: &mut Cursor<&[u8]>, id: u8) -> Result<Nbt, Error> {
Ok(match id {
// Signifies the end of a TAG_Compound. It is only ever used inside
// a TAG_Compound, and is not named despite being in a TAG_Compound
- END_ID => Tag::End,
+ END_ID => Nbt::End,
// A single signed byte
- BYTE_ID => Tag::Byte(stream.read_i8()?),
+ BYTE_ID => Nbt::Byte(stream.read_i8()?),
// A single signed, big endian 16 bit integer
- SHORT_ID => Tag::Short(stream.read_i16::<BE>()?),
+ SHORT_ID => Nbt::Short(stream.read_i16::<BE>()?),
// A single signed, big endian 32 bit integer
- INT_ID => Tag::Int(stream.read_i32::<BE>()?),
+ INT_ID => Nbt::Int(stream.read_i32::<BE>()?),
// A single signed, big endian 64 bit integer
- LONG_ID => Tag::Long(stream.read_i64::<BE>()?),
+ LONG_ID => Nbt::Long(stream.read_i64::<BE>()?),
// A single, big endian IEEE-754 single-precision floating point
// number (NaN possible)
- FLOAT_ID => Tag::Float(stream.read_f32::<BE>()?),
+ FLOAT_ID => Nbt::Float(stream.read_f32::<BE>()?),
// A single, big endian IEEE-754 double-precision floating point
// number (NaN possible)
- DOUBLE_ID => Tag::Double(stream.read_f64::<BE>()?),
+ DOUBLE_ID => Nbt::Double(stream.read_f64::<BE>()?),
// A length-prefixed array of signed bytes. The prefix is a signed
// integer (thus 4 bytes)
- BYTE_ARRAY_ID => Tag::ByteArray(read_byte_array(stream)?),
+ BYTE_ARRAY_ID => Nbt::ByteArray(read_byte_array(stream)?),
// A length-prefixed modified UTF-8 string. The prefix is an
// unsigned short (thus 2 bytes) signifying the length of the
// string in bytes
- STRING_ID => Tag::String(read_string(stream)?),
+ STRING_ID => Nbt::String(read_string(stream)?),
// A list of nameless tags, all of the same type. The list is
// prefixed with the Type ID of the items it contains (thus 1
// byte), and the length of the list as a signed integer (a further
@@ -239,57 +239,57 @@ impl Tag {
// notchian implementation uses TAG_End in that situation, but
// another reference implementation by Mojang uses 1 instead;
// parsers should accept any type if the length is <= 0).
- LIST_ID => Tag::List(read_list(stream)?),
+ LIST_ID => Nbt::List(read_list(stream)?),
// Effectively a list of a named tags. Order is not guaranteed.
- COMPOUND_ID => Tag::Compound(read_compound(stream)?),
+ COMPOUND_ID => Nbt::Compound(read_compound(stream)?),
// A length-prefixed array of signed integers. The prefix is a
// signed integer (thus 4 bytes) and indicates the number of 4 byte
// integers.
- INT_ARRAY_ID => Tag::IntArray(read_int_array(stream)?),
+ INT_ARRAY_ID => Nbt::IntArray(read_int_array(stream)?),
// A length-prefixed array of signed longs. The prefix is a signed
// integer (thus 4 bytes) and indicates the number of 8 byte longs.
- LONG_ARRAY_ID => Tag::LongArray(read_long_array(stream)?),
+ LONG_ARRAY_ID => Nbt::LongArray(read_long_array(stream)?),
_ => return Err(Error::InvalidTagType(id)),
})
}
/// Read the NBT data. This will return a compound tag with a single item.
- pub fn read(stream: &mut Cursor<&[u8]>) -> Result<Tag, Error> {
+ pub fn read(stream: &mut Cursor<&[u8]>) -> Result<Nbt, Error> {
// default to compound tag
// the parent compound only ever has one item
let tag_id = stream.read_u8().unwrap_or(0);
if tag_id == 0 {
- return Ok(Tag::End);
+ return Ok(Nbt::End);
}
let name = read_string(stream)?;
- let tag = Tag::read_known(stream, tag_id)?;
+ let tag = Nbt::read_known(stream, tag_id)?;
let mut map = NbtCompound::with_capacity(1);
map.insert(name, tag);
- Ok(Tag::Compound(map))
+ Ok(Nbt::Compound(map))
}
/// Read the NBT data compressed wtih zlib.
- pub fn read_zlib(stream: &mut impl BufRead) -> Result<Tag, Error> {
+ pub fn read_zlib(stream: &mut impl BufRead) -> Result<Nbt, Error> {
let mut gz = ZlibDecoder::new(stream);
let mut buf = Vec::new();
gz.read_to_end(&mut buf)?;
- Tag::read(&mut Cursor::new(&buf))
+ Nbt::read(&mut Cursor::new(&buf))
}
/// Read the NBT data compressed wtih gzip.
- pub fn read_gzip(stream: &mut Cursor<Vec<u8>>) -> Result<Tag, Error> {
+ pub fn read_gzip(stream: &mut Cursor<Vec<u8>>) -> Result<Nbt, Error> {
let mut gz = GzDecoder::new(stream);
let mut buf = Vec::new();
gz.read_to_end(&mut buf)?;
- Tag::read(&mut Cursor::new(&buf))
+ Nbt::read(&mut Cursor::new(&buf))
}
}
-impl McBufReadable for Tag {
+impl McBufReadable for Nbt {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- Ok(Tag::read(buf)?)
+ Ok(Nbt::read(buf)?)
}
}
impl From<Error> for BufReadError {
diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs
index 4d76fede..79cd39d4 100755
--- a/azalea-nbt/src/encode.rs
+++ b/azalea-nbt/src/encode.rs
@@ -14,63 +14,63 @@ fn write_string(writer: &mut dyn Write, string: &str) {
fn write_compound(writer: &mut dyn Write, value: &NbtCompound, end_tag: bool) {
for (key, tag) in value.iter() {
match tag {
- Tag::End => {}
- Tag::Byte(value) => {
+ Nbt::End => {}
+ Nbt::Byte(value) => {
writer.write_u8(BYTE_ID).unwrap();
write_string(writer, key);
writer.write_i8(*value).unwrap();
}
- Tag::Short(value) => {
+ Nbt::Short(value) => {
writer.write_u8(SHORT_ID).unwrap();
write_string(writer, key);
writer.write_i16::<BE>(*value).unwrap();
}
- Tag::Int(value) => {
+ Nbt::Int(value) => {
writer.write_u8(INT_ID).unwrap();
write_string(writer, key);
writer.write_i32::<BE>(*value).unwrap();
}
- Tag::Long(value) => {
+ Nbt::Long(value) => {
writer.write_u8(LONG_ID).unwrap();
write_string(writer, key);
writer.write_i64::<BE>(*value).unwrap();
}
- Tag::Float(value) => {
+ Nbt::Float(value) => {
writer.write_u8(FLOAT_ID).unwrap();
write_string(writer, key);
writer.write_f32::<BE>(*value).unwrap();
}
- Tag::Double(value) => {
+ Nbt::Double(value) => {
writer.write_u8(DOUBLE_ID).unwrap();
write_string(writer, key);
writer.write_f64::<BE>(*value).unwrap();
}
- Tag::ByteArray(value) => {
+ Nbt::ByteArray(value) => {
writer.write_u8(BYTE_ARRAY_ID).unwrap();
write_string(writer, key);
write_byte_array(writer, value);
}
- Tag::String(value) => {
+ Nbt::String(value) => {
writer.write_u8(STRING_ID).unwrap();
write_string(writer, key);
write_string(writer, value);
}
- Tag::List(value) => {
+ Nbt::List(value) => {
writer.write_u8(LIST_ID).unwrap();
write_string(writer, key);
write_list(writer, value);
}
- Tag::Compound(value) => {
+ Nbt::Compound(value) => {
writer.write_u8(COMPOUND_ID).unwrap();
write_string(writer, key);
write_compound(writer, value, true);
}
- Tag::IntArray(value) => {
+ Nbt::IntArray(value) => {
writer.write_u8(INT_ARRAY_ID).unwrap();
write_string(writer, key);
write_int_array(writer, value);
}
- Tag::LongArray(value) => {
+ Nbt::LongArray(value) => {
writer.write_u8(LONG_ARRAY_ID).unwrap();
write_string(writer, key);
write_long_array(writer, value);
@@ -196,27 +196,27 @@ fn write_long_array(writer: &mut dyn Write, value: &Vec<i64>) {
}
}
-impl Tag {
+impl Nbt {
/// Write the tag as unnamed, uncompressed NBT data. If you're writing a
/// compound tag and the length of the NBT is already known, use
- /// [`Tag::write`] to avoid the `End` tag (this is used when writing NBT to
+ /// [`Nbt::write`] to avoid the `End` tag (this is used when writing NBT to
/// a file).
#[inline]
pub fn write_without_end(&self, writer: &mut dyn Write) {
match self {
- Tag::End => {}
- Tag::Byte(value) => writer.write_i8(*value).unwrap(),
- Tag::Short(value) => writer.write_i16::<BE>(*value).unwrap(),
- Tag::Int(value) => writer.write_i32::<BE>(*value).unwrap(),
- Tag::Long(value) => writer.write_i64::<BE>(*value).unwrap(),
- Tag::Float(value) => writer.write_f32::<BE>(*value).unwrap(),
- Tag::Double(value) => writer.write_f64::<BE>(*value).unwrap(),
- Tag::ByteArray(value) => write_byte_array(writer, value),
- Tag::String(value) => write_string(writer, value),
- Tag::List(value) => write_list(writer, value),
- Tag::Compound(value) => write_compound(writer, value, true),
- Tag::IntArray(value) => write_int_array(writer, value),
- Tag::LongArray(value) => write_long_array(writer, value),
+ Nbt::End => {}
+ Nbt::Byte(value) => writer.write_i8(*value).unwrap(),
+ Nbt::Short(value) => writer.write_i16::<BE>(*value).unwrap(),
+ Nbt::Int(value) => writer.write_i32::<BE>(*value).unwrap(),
+ Nbt::Long(value) => writer.write_i64::<BE>(*value).unwrap(),
+ Nbt::Float(value) => writer.write_f32::<BE>(*value).unwrap(),
+ Nbt::Double(value) => writer.write_f64::<BE>(*value).unwrap(),
+ Nbt::ByteArray(value) => write_byte_array(writer, value),
+ Nbt::String(value) => write_string(writer, value),
+ Nbt::List(value) => write_list(writer, value),
+ Nbt::Compound(value) => write_compound(writer, value, true),
+ Nbt::IntArray(value) => write_int_array(writer, value),
+ Nbt::LongArray(value) => write_long_array(writer, value),
}
}
@@ -227,10 +227,10 @@ impl Tag {
/// Will panic if the tag is not a Compound or End tag.
pub fn write(&self, writer: &mut impl Write) {
match self {
- Tag::Compound(value) => {
+ Nbt::Compound(value) => {
write_compound(writer, value, false);
}
- Tag::End => {
+ Nbt::End => {
END_ID.write_into(writer).unwrap();
}
_ => panic!("Not a compound tag"),
@@ -258,7 +258,7 @@ impl Tag {
}
}
-impl McBufWritable for Tag {
+impl McBufWritable for Nbt {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
self.write(buf);
Ok(())
diff --git a/azalea-nbt/src/lib.rs b/azalea-nbt/src/lib.rs
index 3c8aa2cd..b6a7a971 100755
--- a/azalea-nbt/src/lib.rs
+++ b/azalea-nbt/src/lib.rs
@@ -6,7 +6,7 @@ mod error;
mod tag;
pub use error::Error;
-pub use tag::{NbtCompound, NbtList, Tag};
+pub use tag::{NbtCompound, NbtList, Nbt};
#[cfg(test)]
mod tests {
@@ -20,25 +20,25 @@ mod tests {
#[test]
fn mcbuf_nbt() {
let mut buf = Vec::new();
- let tag = Tag::Compound(NbtCompound::from_iter(vec![(
+ let tag = Nbt::Compound(NbtCompound::from_iter(vec![(
"hello world".into(),
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"name".into(),
- Tag::String("Bananrama".into()),
+ Nbt::String("Bananrama".into()),
)])),
)]));
tag.write_into(&mut buf).unwrap();
let mut buf = Cursor::new(&buf[..]);
- let result = Tag::read_from(&mut buf).unwrap();
+ let result = Nbt::read_from(&mut buf).unwrap();
assert_eq!(
result,
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"hello world".into(),
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"name".into(),
- Tag::String("Bananrama".into()),
+ Nbt::String("Bananrama".into()),
)])),
)]))
);
diff --git a/azalea-nbt/src/tag.rs b/azalea-nbt/src/tag.rs
index 7e4c5e25..573867ab 100755
--- a/azalea-nbt/src/tag.rs
+++ b/azalea-nbt/src/tag.rs
@@ -32,7 +32,7 @@ pub const LONG_ARRAY_ID: u8 = 12;
#[derive(Clone, Debug, PartialEq, Default, EnumAsInner)]
#[repr(u8)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(untagged))]
-pub enum Tag {
+pub enum Nbt {
#[default]
End = END_ID,
Byte(NbtByte) = BYTE_ID,
@@ -69,7 +69,7 @@ pub enum NbtList {
LongArray(Vec<NbtLongArray>) = LONG_ARRAY_ID,
}
-impl Tag {
+impl Nbt {
/// Get the numerical ID of the tag type.
#[inline]
pub fn id(&self) -> u8 {
@@ -96,7 +96,7 @@ impl NbtList {
#[derive(Debug, Clone, Default)]
pub struct NbtCompound {
sorted: bool,
- inner: Vec<(NbtString, Tag)>,
+ inner: Vec<(NbtString, Nbt)>,
}
impl NbtCompound {
#[inline]
@@ -117,7 +117,7 @@ impl NbtCompound {
/// If you previously used [`Self::insert_unsorted`] without [`Self::sort`],
/// this function may return incorrect results.
#[inline]
- pub fn get(&mut self, key: &NbtString) -> Option<&Tag> {
+ pub fn get(&mut self, key: &NbtString) -> Option<&Nbt> {
if !self.sorted {
self.sort()
}
@@ -131,7 +131,7 @@ impl NbtCompound {
/// [`Self::insert_unsorted`] and then [`Self::sort`] after everything is
/// inserted.
#[inline]
- pub fn insert(&mut self, key: NbtString, value: Tag) {
+ pub fn insert(&mut self, key: NbtString, value: Nbt) {
self.inner.push((key, value));
}
@@ -142,7 +142,7 @@ impl NbtCompound {
}
#[inline]
- pub fn iter(&self) -> std::slice::Iter<'_, (CompactString, Tag)> {
+ pub fn iter(&self) -> std::slice::Iter<'_, (CompactString, Nbt)> {
self.inner.iter()
}
}
@@ -160,7 +160,7 @@ impl Serialize for NbtCompound {
impl<'de> Deserialize<'de> for NbtCompound {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::collections::BTreeMap;
- let map = <BTreeMap<NbtString, Tag> as Deserialize>::deserialize(deserializer)?;
+ let map = <BTreeMap<NbtString, Nbt> as Deserialize>::deserialize(deserializer)?;
Ok(Self {
inner: map.into_iter().collect(),
sorted: false,
@@ -168,8 +168,8 @@ impl<'de> Deserialize<'de> for NbtCompound {
}
}
-impl FromIterator<(NbtString, Tag)> for NbtCompound {
- fn from_iter<T: IntoIterator<Item = (NbtString, Tag)>>(iter: T) -> Self {
+impl FromIterator<(NbtString, Nbt)> for NbtCompound {
+ fn from_iter<T: IntoIterator<Item = (NbtString, Nbt)>>(iter: T) -> Self {
let inner = iter.into_iter().collect::<Vec<_>>();
Self {
inner,
diff --git a/azalea-nbt/tests/tests.rs b/azalea-nbt/tests/tests.rs
index 1555d7fa..a7f6912f 100755
--- a/azalea-nbt/tests/tests.rs
+++ b/azalea-nbt/tests/tests.rs
@@ -1,18 +1,18 @@
-use azalea_nbt::{NbtCompound, NbtList, Tag};
+use azalea_nbt::{NbtCompound, NbtList, Nbt};
use std::io::Cursor;
#[test]
fn test_decode_hello_world() {
// read hello_world.nbt
let buf = include_bytes!("hello_world.nbt").to_vec();
- let tag = Tag::read(&mut Cursor::new(&buf[..])).unwrap();
+ let tag = Nbt::read(&mut Cursor::new(&buf[..])).unwrap();
assert_eq!(
tag,
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"hello world".into(),
- Tag::Compound(NbtCompound::from_iter(vec![(
+ Nbt::Compound(NbtCompound::from_iter(vec![(
"name".into(),
- Tag::String("Bananrama".into()),
+ Nbt::String("Bananrama".into()),
)]))
)]))
);
@@ -23,7 +23,7 @@ fn test_roundtrip_hello_world() {
let original = include_bytes!("hello_world.nbt").to_vec();
let mut original_stream = Cursor::new(&original[..]);
- let tag = Tag::read(&mut original_stream).unwrap();
+ let tag = Nbt::read(&mut original_stream).unwrap();
// write hello_world.nbt
let mut result = Vec::new();
@@ -38,21 +38,21 @@ fn test_bigtest() {
let original = include_bytes!("bigtest.nbt").to_vec();
let mut original_stream = Cursor::new(original);
- let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
+ let original_tag = Nbt::read_gzip(&mut original_stream).unwrap();
let mut result = Vec::new();
original_tag.write(&mut result);
- let decoded_tag = Tag::read(&mut Cursor::new(&result)).unwrap();
+ let decoded_tag = Nbt::read(&mut Cursor::new(&result)).unwrap();
assert_eq!(decoded_tag, original_tag);
}
#[test]
fn test_stringtest() {
- let correct_tag = Tag::Compound(NbtCompound::from_iter(vec![(
+ let correct_tag = Nbt::Compound(NbtCompound::from_iter(vec![(
"😃".into(),
- Tag::List(NbtList::String(vec![
+ Nbt::List(NbtList::String(vec![
"asdfkghasfjgihsdfogjsndfg".into(),
"jnabsfdgihsabguiqwrntgretqwejirhbiqw".into(),
"asd".into(),
@@ -74,7 +74,7 @@ fn test_stringtest() {
let original = include_bytes!("stringtest.nbt").to_vec();
let mut original_stream = Cursor::new(original);
- let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
+ let original_tag = Nbt::read_gzip(&mut original_stream).unwrap();
assert_eq!(original_tag, correct_tag);
}
@@ -84,12 +84,12 @@ fn test_complex_player() {
let original = include_bytes!("complex_player.dat").to_vec();
let mut original_stream = Cursor::new(original);
- let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
+ let original_tag = Nbt::read_gzip(&mut original_stream).unwrap();
let mut result = Vec::new();
original_tag.write(&mut result);
- let decoded_tag = Tag::read(&mut Cursor::new(&result)).unwrap();
+ let decoded_tag = Nbt::read(&mut Cursor::new(&result)).unwrap();
assert_eq!(decoded_tag, original_tag);
}
@@ -99,12 +99,12 @@ fn test_simple_player() {
let original = include_bytes!("simple_player.dat").to_vec();
let mut original_stream = Cursor::new(original);
- let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
+ let original_tag = Nbt::read_gzip(&mut original_stream).unwrap();
let mut result = Vec::new();
original_tag.write(&mut result);
- let decoded_tag = Tag::read(&mut Cursor::new(&result)).unwrap();
+ let decoded_tag = Nbt::read(&mut Cursor::new(&result)).unwrap();
assert_eq!(decoded_tag, original_tag);
}
diff --git a/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs
index e3c95034..fda1bd43 100755
--- a/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs
@@ -6,5 +6,5 @@ use azalea_protocol_macros::ClientboundGamePacket;
pub struct ClientboundBlockEntityDataPacket {
pub pos: BlockPos,
pub block_entity_type: azalea_registry::BlockEntityKind,
- pub tag: azalea_nbt::Tag,
+ pub tag: azalea_nbt::Nbt,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
index 1a8cf3df..30813013 100755
--- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
@@ -13,7 +13,7 @@ pub struct ClientboundLevelChunkWithLightPacket {
#[derive(Clone, Debug, McBuf)]
pub struct ClientboundLevelChunkPacketData {
- pub heightmaps: azalea_nbt::Tag,
+ pub heightmaps: azalea_nbt::Nbt,
// we can't parse the data in azalea-protocol because it dependso on context from other packets
pub data: Vec<u8>,
pub block_entities: Vec<BlockEntity>,
@@ -25,5 +25,5 @@ pub struct BlockEntity {
pub y: u16,
#[var]
pub type_: i32,
- pub data: azalea_nbt::Tag,
+ pub data: azalea_nbt::Nbt,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_login_packet.rs b/azalea-protocol/src/packets/game/clientbound_login_packet.rs
index 37273b03..42f93c40 100755
--- a/azalea-protocol/src/packets/game/clientbound_login_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_login_packet.rs
@@ -42,7 +42,7 @@ pub mod registry {
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
use azalea_core::ResourceLocation;
- use azalea_nbt::Tag;
+ use azalea_nbt::Nbt;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::{collections::HashMap, io::Cursor};
@@ -58,32 +58,32 @@ pub mod registry {
pub root: RegistryRoot,
}
- impl TryFrom<Tag> for RegistryHolder {
+ impl TryFrom<Nbt> for RegistryHolder {
type Error = serde_json::Error;
- fn try_from(value: Tag) -> Result<Self, Self::Error> {
+ fn try_from(value: Nbt) -> Result<Self, Self::Error> {
serde_json::from_value(serde_json::to_value(value)?)
}
}
- impl TryInto<Tag> for RegistryHolder {
+ impl TryInto<Nbt> for RegistryHolder {
type Error = serde_json::Error;
- fn try_into(self) -> Result<Tag, Self::Error> {
+ fn try_into(self) -> Result<Nbt, Self::Error> {
serde_json::from_value(serde_json::to_value(self)?)
}
}
impl McBufReadable for RegistryHolder {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- RegistryHolder::try_from(Tag::read_from(buf)?)
+ RegistryHolder::try_from(Nbt::read_from(buf)?)
.map_err(|e| BufReadError::Deserialization { source: e })
}
}
impl McBufWritable for RegistryHolder {
fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- TryInto::<Tag>::try_into(self.clone())?.write_into(buf)
+ TryInto::<Nbt>::try_into(self.clone())?.write_into(buf)
}
}
@@ -100,14 +100,14 @@ pub mod registry {
pub trim_material: RegistryType<TrimMaterialElement>,
#[cfg(not(feature = "strict_registry"))]
#[serde(rename = "minecraft:trim_material")]
- pub trim_material: Tag,
+ pub trim_material: Nbt,
#[cfg(feature = "strict_registry")]
#[serde(rename = "minecraft:chat_type")]
pub chat_type: RegistryType<ChatTypeElement>,
#[cfg(not(feature = "strict_registry"))]
#[serde(rename = "minecraft:chat_type")]
- pub chat_type: Tag,
+ pub chat_type: Nbt,
#[serde(rename = "minecraft:dimension_type")]
pub dimension_type: RegistryType<DimensionTypeElement>,
@@ -117,21 +117,21 @@ pub mod registry {
pub world_type: RegistryType<WorldTypeElement>,
#[cfg(not(feature = "strict_registry"))]
#[serde(rename = "minecraft:worldgen/biome")]
- pub world_type: Tag,
+ pub world_type: Nbt,
#[cfg(feature = "strict_registry")]
#[serde(rename = "minecraft:trim_pattern")]
pub trim_pattern: RegistryType<TrimPatternElement>,
#[cfg(not(feature = "strict_registry"))]
#[serde(rename = "minecraft:trim_pattern")]
- pub trim_pattern: Tag,
+ pub trim_pattern: Nbt,
#[cfg(feature = "strict_registry")]
#[serde(rename = "minecraft:damage_type")]
pub damage_type: RegistryType<DamageTypeElement>,
#[cfg(not(feature = "strict_registry"))]
#[serde(rename = "minecraft:damage_type")]
- pub damage_type: Tag,
+ pub damage_type: Nbt,
}
/// A collection of values for a certain type of registry data.
@@ -481,27 +481,27 @@ pub mod registry {
mod tests {
use super::registry::{DimensionTypeElement, RegistryHolder, RegistryRoot, RegistryType};
use azalea_core::ResourceLocation;
- use azalea_nbt::Tag;
+ use azalea_nbt::Nbt;
#[test]
fn test_convert() {
- // Do NOT use Tag::End, they should be Tag::Compound.
+ // Do NOT use Nbt::End, they should be Nbt::Compound.
// This is just for testing.
let registry = RegistryHolder {
root: RegistryRoot {
- trim_material: Tag::End,
- chat_type: Tag::End,
+ trim_material: Nbt::End,
+ chat_type: Nbt::End,
dimension_type: RegistryType::<DimensionTypeElement> {
kind: ResourceLocation::new("minecraft:dimension_type"),
value: Vec::new(),
},
- world_type: Tag::End,
- trim_pattern: Tag::End,
- damage_type: Tag::End,
+ world_type: Nbt::End,
+ trim_pattern: Nbt::End,
+ damage_type: Nbt::End,
},
};
- let tag: Tag = registry.try_into().unwrap();
+ let tag: Nbt = registry.try_into().unwrap();
let root = tag
.as_compound()
.unwrap()
diff --git a/azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs b/azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs
index ff9f4ba1..db238f66 100755
--- a/azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_tag_query_packet.rs
@@ -5,5 +5,5 @@ use azalea_protocol_macros::ClientboundGamePacket;
pub struct ClientboundTagQueryPacket {
#[var]
pub transaction_id: u32,
- pub tag: azalea_nbt::Tag,
+ pub tag: azalea_nbt::Nbt,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs
index d1d9f9cc..c43d64bb 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_mob_effect_packet.rs
@@ -10,5 +10,5 @@ pub struct ClientboundUpdateMobEffectPacket {
#[var]
pub effect_duration_ticks: u32,
pub flags: u8,
- pub factor_data: Option<azalea_nbt::Tag>,
+ pub factor_data: Option<azalea_nbt::Nbt>,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
index 937a1220..318adb7f 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
@@ -22,7 +22,7 @@ pub struct Recipe {
#[derive(Clone, Debug, McBuf)]
pub struct ShapelessRecipe {
/// Used to group similar recipes together in the recipe book.
- /// Tag is present in recipe JSON
+ /// Nbt is present in recipe JSON
pub group: String,
pub category: CraftingBookCategory,
pub ingredients: Vec<Ingredient>,
diff --git a/azalea-world/src/entity/data.rs b/azalea-world/src/entity/data.rs
index 664efe1c..c761a786 100755
--- a/azalea-world/src/entity/data.rs
+++ b/azalea-world/src/entity/data.rs
@@ -70,7 +70,7 @@ pub enum EntityDataValue {
BlockState(azalea_block::BlockState),
/// If this is air, that means it's absent,
OptionalBlockState(azalea_block::BlockState),
- CompoundTag(azalea_nbt::Tag),
+ CompoundTag(azalea_nbt::Nbt),
Particle(Particle),
VillagerData(VillagerData),
// 0 for absent; 1 + actual value otherwise. Used for entity IDs.
diff --git a/azalea-world/src/entity/metadata.rs b/azalea-world/src/entity/metadata.rs
index 0b1dedd3..f7b19744 100644
--- a/azalea-world/src/entity/metadata.rs
+++ b/azalea-world/src/entity/metadata.rs
@@ -6023,9 +6023,9 @@ pub struct PlayerModeCustomisation(pub u8);
#[derive(Component, Deref, DerefMut, Clone)]
pub struct PlayerMainHand(pub u8);
#[derive(Component, Deref, DerefMut, Clone)]
-pub struct ShoulderLeft(pub azalea_nbt::Tag);
+pub struct ShoulderLeft(pub azalea_nbt::Nbt);
#[derive(Component, Deref, DerefMut, Clone)]
-pub struct ShoulderRight(pub azalea_nbt::Tag);
+pub struct ShoulderRight(pub azalea_nbt::Nbt);
#[derive(Component)]
pub struct Player;
impl Player {
@@ -6106,8 +6106,8 @@ impl Default for PlayerMetadataBundle {
score: Score(0),
player_mode_customisation: PlayerModeCustomisation(0),
player_main_hand: PlayerMainHand(1),
- shoulder_left: ShoulderLeft(azalea_nbt::Tag::Compound(Default::default())),
- shoulder_right: ShoulderRight(azalea_nbt::Tag::Compound(Default::default())),
+ shoulder_left: ShoulderLeft(azalea_nbt::Nbt::Compound(Default::default())),
+ shoulder_right: ShoulderRight(azalea_nbt::Nbt::Compound(Default::default())),
}
}
}
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index 23a94c52..c787ffd4 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -399,7 +399,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
if default is None:
# some types don't have Default implemented
if type_name == 'CompoundTag':
- default = 'azalea_nbt::Tag::Compound(Default::default())'
+ default = 'azalea_nbt::Nbt::Compound(Default::default())'
elif type_name == 'CatVariant':
default = 'azalea_registry::CatVariant::Tabby'
elif type_name == 'PaintingVariant':
@@ -433,7 +433,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
elif type_name == 'OptionalFormattedText':
default = f'Some({default})' if default != 'Empty' else 'None'
elif type_name == 'CompoundTag':
- default = f'azalea_nbt::Tag::Compound({default})' if default != 'Empty' else 'azalea_nbt::Tag::Compound(Default::default())'
+ default = f'azalea_nbt::Nbt::Compound({default})' if default != 'Empty' else 'azalea_nbt::Nbt::Compound(Default::default())'
elif type_name == 'Quaternion':
default = f'Quaternion {{ x: {float(default["x"])}, y: {float(default["y"])}, z: {float(default["z"])}, w: {float(default["w"])} }}'
elif type_name == 'Vector3':
diff --git a/codegen/lib/code/utils.py b/codegen/lib/code/utils.py
index aaa166ff..3f9b6edb 100755
--- a/codegen/lib/code/utils.py
+++ b/codegen/lib/code/utils.py
@@ -56,7 +56,7 @@ def burger_type_to_rust_type(burger_type, field_name: Optional[str] = None, inst
field_type_rs = 'BlockPos'
uses.add('azalea_core::BlockPos')
elif burger_type == 'nbtcompound':
- field_type_rs = 'azalea_nbt::Tag'
+ field_type_rs = 'azalea_nbt::Nbt'
elif burger_type == 'itemstack':
field_type_rs = 'Slot'
uses.add('azalea_core::Slot')