aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt
diff options
context:
space:
mode:
authorEightFactorial <murphkev000@gmail.com>2022-12-06 18:48:48 -0800
committerGitHub <noreply@github.com>2022-12-06 20:48:48 -0600
commit9f5e5c092be9167e4d5222fdee4a1d2c419e5052 (patch)
tree1d0a8b57434e0afd14b4a02cbbc579a3ad70da61 /azalea-nbt
parente99a822995c80e1f95c5f7a69e0d8c5d131af20f (diff)
downloadazalea-drasl-9f5e5c092be9167e4d5222fdee4a1d2c419e5052.tar.xz
Complete ClientboundCommand{Suggestion}sPacket, Serde support for NBT Tags (#49)
* Serializing ClientboundStatusResponsePacket Enable serialization of ClientboundStatusResponsePacket * Update clientbound_status_response_packet.rs Add options previewsChat and enforcesSecureChat * Serialize Style and TextColor * Serialize BaseComponent * Serialize TextComponent * Fix Style * Serialize Component * Fix multiple formats per message, fix reset tag * Fix Style, again * Use FlatMapSerializer * Forgot italics * Count struct fields, reorganize logic * Serialize TranslatableComponent * Rewrite TextComponent Serializer * Fix using TextColor::Parse * Code Cleanup * Add default attribute, just in case * Clippy * use serde derive feature + preferred formatting choices * McBufWritable for BrigadierNodeStub * Thanks Clippy... * Implement suggestions in azalea-brigadier * Serde support for NBT Tags * Serde options * Forgot Options * Oops, that's McBufWritable for BrigadierParser * Fix McBufWritable for SlotData * Complete ClientboundUpdateRecipesPacket * fix some issues * better impl McBufReadable for Suggestions Co-authored-by: BuildTools <unconfigured@null.spigotmc.org> Co-authored-by: mat <github@matdoes.dev>
Diffstat (limited to 'azalea-nbt')
-rwxr-xr-xazalea-nbt/Cargo.toml3
-rwxr-xr-xazalea-nbt/README.md2
-rwxr-xr-xazalea-nbt/src/encode.rs4
-rwxr-xr-xazalea-nbt/src/tag.rs4
4 files changed, 9 insertions, 4 deletions
diff --git a/azalea-nbt/Cargo.toml b/azalea-nbt/Cargo.toml
index 11cad33d..1ff52cdd 100755
--- a/azalea-nbt/Cargo.toml
+++ b/azalea-nbt/Cargo.toml
@@ -9,13 +9,14 @@ repository = "https://github.com/mat-1/azalea/tree/main/azalea-nbt"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-ahash = "^0.8.0"
+ahash = { version = "^0.8.0", features = ["serde"]}
azalea-buf = {path = "../azalea-buf", version = "^0.4.0" }
byteorder = "^1.4.3"
flate2 = "^1.0.23"
log = "0.4.17"
num-derive = "^0.3.3"
num-traits = "^0.2.14"
+serde = {version = "^1.0.148", features = ["derive"]}
[dev-dependencies]
criterion = {version = "^0.3.5", features = ["html_reports"]}
diff --git a/azalea-nbt/README.md b/azalea-nbt/README.md
index 4d5cecc4..19498cf3 100755
--- a/azalea-nbt/README.md
+++ b/azalea-nbt/README.md
@@ -1,5 +1,3 @@
# Azalea NBT
A fast NBT serializer and deserializer.
-
-TODO: serde support for fast registry_holder parsing in azalea-client
diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs
index 49c31192..87464fd9 100755
--- a/azalea-nbt/src/encode.rs
+++ b/azalea-nbt/src/encode.rs
@@ -193,6 +193,10 @@ impl Tag {
write_compound(writer, value, false)?;
Ok(())
}
+ Tag::End => {
+ 0u8.write_into(writer)?;
+ Ok(())
+ }
_ => Err(Error::InvalidTag),
}
}
diff --git a/azalea-nbt/src/tag.rs b/azalea-nbt/src/tag.rs
index de57b0a2..2bebe156 100755
--- a/azalea-nbt/src/tag.rs
+++ b/azalea-nbt/src/tag.rs
@@ -1,6 +1,8 @@
use ahash::AHashMap;
+use serde::{Deserialize, Serialize};
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[serde(untagged)]
pub enum Tag {
End, // 0
Byte(i8), // 1