diff options
| author | mat <git@matdoes.dev> | 2025-08-18 16:42:48 -0545 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-08-18 16:42:48 -0545 |
| commit | 9c39e05d37926de13588777ecd84f34d2f6e0a1d (patch) | |
| tree | ae6427df80f5e96a1e9f7370de30d398d917c5fa /azalea-inventory/src | |
| parent | c2ada754f9888fe791a5f604534c55cc6da71590 (diff) | |
| download | azalea-drasl-9c39e05d37926de13588777ecd84f34d2f6e0a1d.tar.xz | |
fix ClientboundMerchantOffers
Diffstat (limited to 'azalea-inventory/src')
| -rw-r--r-- | azalea-inventory/src/components.rs | 10 | ||||
| -rw-r--r-- | azalea-inventory/src/slot.rs | 11 |
2 files changed, 18 insertions, 3 deletions
diff --git a/azalea-inventory/src/components.rs b/azalea-inventory/src/components.rs index 3da393e5..f63ca1ad 100644 --- a/azalea-inventory/src/components.rs +++ b/azalea-inventory/src/components.rs @@ -130,11 +130,15 @@ macro_rules! define_data_components { pub unsafe fn azalea_write_as( &self, kind: registry::DataComponentKind, - buf: &mut Vec<u8>, + buf: &mut impl std::io::Write, ) -> io::Result<()> { + let mut value = Vec::new(); match kind { - $( DataComponentKind::$x => unsafe { self.$x.encode(buf) }, )* - } + $( DataComponentKind::$x => unsafe { self.$x.encode(&mut value)? }, )* + }; + buf.write_all(&value)?; + + Ok(()) } /// # Safety /// diff --git a/azalea-inventory/src/slot.rs b/azalea-inventory/src/slot.rs index e9da4856..2d4202e8 100644 --- a/azalea-inventory/src/slot.rs +++ b/azalea-inventory/src/slot.rs @@ -349,6 +349,17 @@ impl DataComponentPatch { ) }) } + /// Insert a new component into this patch, or mark a component as removed. + /// + /// # Safety + /// The [`DataComponentUnion`] must be of the correct kind. + pub unsafe fn unchecked_insert_component( + &mut self, + kind: DataComponentKind, + value: Option<DataComponentUnion>, + ) { + self.components.insert(kind, value); + } } impl Drop for DataComponentPatch { |
