diff options
| author | mat <git@matdoes.dev> | 2023-10-26 23:13:26 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-26 23:13:26 -0500 |
| commit | 48b5d121718c98c3280e0945508324fc4527beec (patch) | |
| tree | b99fa869f2d431cb6c8736d1577b1a8f0c05e989 | |
| parent | 2803e9ef0d785538a23adceba44d45b162629979 (diff) | |
| download | azalea-drasl-48b5d121718c98c3280e0945508324fc4527beec.tar.xz | |
remove some unnecessary code and improve docs for Menu
| -rwxr-xr-x | azalea-buf/src/read.rs | 12 | ||||
| -rwxr-xr-x | azalea-buf/src/write.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/lib.rs | 1 | ||||
| -rw-r--r-- | azalea-inventory/src/operations.rs | 3 | ||||
| -rw-r--r-- | azalea/src/container.rs | 4 |
5 files changed, 19 insertions, 13 deletions
diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 7c996f20..8b37ff6a 100755 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -175,7 +175,7 @@ impl<T: McBufReadable + Send> McBufReadable for Vec<T> { let length = u32::var_read_from(buf)? as usize; // we don't set the capacity here so we can't get exploited into // allocating a bunch - let mut contents = vec![]; + let mut contents = Vec::new(); for _ in 0..length { contents.push(T::read_from(buf)?); } @@ -184,7 +184,7 @@ impl<T: McBufReadable + Send> McBufReadable for Vec<T> { } impl<K: McBufReadable + Send + Eq + Hash, V: McBufReadable + Send> McBufReadable for HashMap<K, V> { - default fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let length = i32::var_read_from(buf)? as usize; let mut contents = HashMap::new(); for _ in 0..length { @@ -197,7 +197,7 @@ impl<K: McBufReadable + Send + Eq + Hash, V: McBufReadable + Send> McBufReadable impl<K: McBufReadable + Send + Eq + Hash, V: McBufVarReadable + Send> McBufVarReadable for HashMap<K, V> { - default fn var_read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + fn var_read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let length = i32::var_read_from(buf)? as usize; let mut contents = HashMap::new(); for _ in 0..length { @@ -308,7 +308,7 @@ impl McBufReadable for f64 { } impl<T: McBufReadable> McBufReadable for Option<T> { - default fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let present = bool::read_from(buf)?; Ok(if present { Some(T::read_from(buf)?) @@ -319,7 +319,7 @@ impl<T: McBufReadable> McBufReadable for Option<T> { } impl<T: McBufVarReadable> McBufVarReadable for Option<T> { - default fn var_read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + fn var_read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let present = bool::read_from(buf)?; Ok(if present { Some(T::var_read_from(buf)?) @@ -331,7 +331,7 @@ impl<T: McBufVarReadable> McBufVarReadable for Option<T> { // [String; 4] impl<T: McBufReadable, const N: usize> McBufReadable for [T; N] { - default fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let mut contents = Vec::with_capacity(N); for _ in 0..N { contents.push(T::read_from(buf)?); diff --git a/azalea-buf/src/write.rs b/azalea-buf/src/write.rs index 161f8645..f48bf2ec 100755 --- a/azalea-buf/src/write.rs +++ b/azalea-buf/src/write.rs @@ -64,7 +64,7 @@ impl<T: McBufWritable> McBufWritable for Vec<T> { } impl<T: McBufWritable> McBufWritable for [T] { - default fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { (self.len() as u32).var_write_into(buf)?; for item in self { T::write_into(item, buf)?; @@ -74,7 +74,7 @@ impl<T: McBufWritable> McBufWritable for [T] { } impl<K: McBufWritable, V: McBufWritable> McBufWritable for HashMap<K, V> { - default fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { u32::var_write_into(&(self.len() as u32), buf)?; for (key, value) in self { key.write_into(buf)?; @@ -86,7 +86,7 @@ impl<K: McBufWritable, V: McBufWritable> McBufWritable for HashMap<K, V> { } impl<K: McBufWritable, V: McBufVarWritable> McBufVarWritable for HashMap<K, V> { - default fn var_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn var_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { u32::var_write_into(&(self.len() as u32), buf)?; for (key, value) in self { key.write_into(buf)?; @@ -225,7 +225,7 @@ impl McBufWritable for f64 { } impl<T: McBufWritable> McBufWritable for Option<T> { - default fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { if let Some(s) = self { true.write_into(buf)?; s.write_into(buf)?; @@ -237,7 +237,7 @@ impl<T: McBufWritable> McBufWritable for Option<T> { } impl<T: McBufVarWritable> McBufVarWritable for Option<T> { - default fn var_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn var_write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { if let Some(s) = self { true.write_into(buf)?; s.var_write_into(buf)?; @@ -250,7 +250,7 @@ impl<T: McBufVarWritable> McBufVarWritable for Option<T> { // [T; N] impl<T: McBufWritable, const N: usize> McBufWritable for [T; N] { - default fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { for i in self { i.write_into(buf)?; } diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs index 25c75bcf..a7231ffc 100644 --- a/azalea-client/src/lib.rs +++ b/azalea-client/src/lib.rs @@ -8,7 +8,6 @@ #![allow(incomplete_features)] #![feature(trait_upcasting)] #![feature(error_generic_member_access)] -#![feature(type_alias_impl_trait)] mod account; pub mod attack; diff --git a/azalea-inventory/src/operations.rs b/azalea-inventory/src/operations.rs index 8d81b18e..29d61bd8 100644 --- a/azalea-inventory/src/operations.rs +++ b/azalea-inventory/src/operations.rs @@ -263,6 +263,9 @@ pub enum ClickType { impl Menu { /// Shift-click a slot in this menu. + /// + /// Keep in mind that this doesn't send any packets to the server, it just + /// mutates this specific `Menu`. pub fn quick_move_stack(&mut self, slot_index: usize) -> ItemSlot { let slot = self.slot(slot_index); if slot.is_none() { diff --git a/azalea/src/container.rs b/azalea/src/container.rs index 221b80b9..f5ac710e 100644 --- a/azalea/src/container.rs +++ b/azalea/src/container.rs @@ -137,6 +137,10 @@ impl ContainerHandle { /// Returns the menu of the container. If the container is closed, this /// will return `None`. + /// + /// Note that any modifications you make to the `Menu` you're given will not + /// actually cause any packets to be sent. If you're trying to modify your + /// inventory, use [`Self::open_inventory`] instead pub fn menu(&self) -> Option<Menu> { let ecs = self.client.ecs.lock(); let inventory = ecs |
