aboutsummaryrefslogtreecommitdiff
path: root/azalea-inventory/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-10-07 06:01:19 +0400
committermat <git@matdoes.dev>2025-10-07 06:01:19 +0400
commit1cf6d92f1a8be954f6885704c31f317b99b05972 (patch)
treeab241a7b6fda815e777b914a8a9a153d23e81f06 /azalea-inventory/src
parent06807ec3ea7df6e83eed51b38f9d5e3bea9e7045 (diff)
downloadazalea-drasl-1cf6d92f1a8be954f6885704c31f317b99b05972.tar.xz
update ResolvableProfile data component to 1.21.9
Diffstat (limited to 'azalea-inventory/src')
-rw-r--r--azalea-inventory/src/components/mod.rs (renamed from azalea-inventory/src/components.rs)23
-rw-r--r--azalea-inventory/src/components/profile.rs73
2 files changed, 76 insertions, 20 deletions
diff --git a/azalea-inventory/src/components.rs b/azalea-inventory/src/components/mod.rs
index b820afc9..5661547a 100644
--- a/azalea-inventory/src/components.rs
+++ b/azalea-inventory/src/components/mod.rs
@@ -1,3 +1,5 @@
+mod profile;
+
use core::f64;
use std::{
any::Any,
@@ -21,10 +23,10 @@ use azalea_registry::{
self as registry, Attribute, Block, DamageKind, DataComponentKind, Enchantment, EntityKind,
Holder, HolderSet, Item, MobEffect, Potion, SoundEvent, TrimMaterial, TrimPattern,
};
+pub use profile::*;
use serde::{Serialize, ser::SerializeMap};
use simdnbt::owned::{Nbt, NbtCompound};
use tracing::trace;
-use uuid::Uuid;
use crate::{ItemStack, item::consume_effect::ConsumeEffect};
@@ -835,25 +837,6 @@ impl Default for Fireworks {
}
#[derive(Clone, PartialEq, AzBuf, Debug, Serialize)]
-pub struct GameProfileProperty {
- pub name: String,
- pub value: String,
- #[serde(skip_serializing_if = "is_default")]
- pub signature: Option<String>,
-}
-
-#[derive(Clone, PartialEq, AzBuf, Debug, Serialize)]
-pub struct Profile {
- #[serde(skip_serializing_if = "is_default")]
- pub name: Option<String>,
- #[serde(skip_serializing_if = "is_default")]
- #[serde(serialize_with = "azalea_core::codec_utils::uuid")]
- pub id: Option<Uuid>,
- #[serde(skip_serializing_if = "is_default")]
- pub properties: Vec<GameProfileProperty>,
-}
-
-#[derive(Clone, PartialEq, AzBuf, Debug, Serialize)]
#[serde(transparent)]
pub struct NoteBlockSound {
pub sound: ResourceLocation,
diff --git a/azalea-inventory/src/components/profile.rs b/azalea-inventory/src/components/profile.rs
new file mode 100644
index 00000000..9966bc8f
--- /dev/null
+++ b/azalea-inventory/src/components/profile.rs
@@ -0,0 +1,73 @@
+use azalea_auth::game_profile::{
+ GameProfile, GameProfileProperties, SerializableProfileProperties,
+};
+use azalea_buf::AzBuf;
+use azalea_core::{codec_utils::*, resource_location::ResourceLocation};
+use serde::{Serialize, Serializer};
+use uuid::Uuid;
+
+#[derive(Clone, Debug, AzBuf, Default, PartialEq, Serialize)]
+#[doc(alias = "ResolvableProfile")]
+pub struct Profile {
+ #[serde(flatten)]
+ pub unpack: Box<PartialOrFullProfile>,
+ #[serde(flatten)]
+ pub skin_patch: Box<PlayerSkinPatch>,
+}
+
+#[derive(Clone, Debug, AzBuf, PartialEq, Serialize)]
+#[serde(untagged)]
+pub enum PartialOrFullProfile {
+ Partial(PartialProfile),
+ Full(GameProfile),
+}
+impl Default for PartialOrFullProfile {
+ fn default() -> Self {
+ Self::Partial(PartialProfile::default())
+ }
+}
+
+#[derive(Clone, Debug, AzBuf, Default, PartialEq, Serialize)]
+pub struct PartialProfile {
+ #[limit(16)]
+ #[serde(skip_serializing_if = "is_default")]
+ pub name: Option<String>,
+ #[serde(skip_serializing_if = "is_default")]
+ pub id: Option<Uuid>,
+ #[serde(serialize_with = "serialize_properties")]
+ pub properties: GameProfileProperties,
+}
+fn serialize_properties<S: Serializer>(
+ properties: &GameProfileProperties,
+ serializer: S,
+) -> Result<S::Ok, S::Error> {
+ let serializable = SerializableProfileProperties::from(properties.clone());
+ serializable.serialize(serializer)
+}
+
+#[derive(Clone, Debug, AzBuf, Default, PartialEq, Serialize)]
+pub struct PlayerSkinPatch {
+ #[serde(rename = "texture")]
+ #[serde(skip_serializing_if = "is_default")]
+ pub body: Option<ResourceTexture>,
+ #[serde(skip_serializing_if = "is_default")]
+ pub cape: Option<ResourceTexture>,
+ #[serde(skip_serializing_if = "is_default")]
+ pub elytra: Option<ResourceTexture>,
+ #[serde(skip_serializing_if = "is_default")]
+ pub model: Option<PlayerModelType>,
+}
+
+#[derive(Clone, Debug, Copy, AzBuf, Default, PartialEq, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum PlayerModelType {
+ #[default]
+ Wide,
+ Slim,
+}
+
+#[derive(Clone, Debug, AzBuf, PartialEq, Serialize)]
+#[serde(transparent)]
+pub struct ResourceTexture {
+ pub id: ResourceLocation,
+}