mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Damage_Event unsigned subtract from zero (#86)
This commit is contained in:
parent
ac680d39f2
commit
2907902431
1 changed files with 9 additions and 4 deletions
|
@ -16,15 +16,20 @@ pub struct ClientboundDamageEventPacket {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OptionalEntityId(pub u32);
|
||||
pub struct OptionalEntityId(pub Option<u32>);
|
||||
impl McBufReadable for OptionalEntityId {
|
||||
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
|
||||
Ok(OptionalEntityId(u32::var_read_from(buf)? - 1))
|
||||
match u32::var_read_from(buf)? {
|
||||
0 => Ok(OptionalEntityId(None)),
|
||||
id => Ok(OptionalEntityId(Some(id - 1))),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl McBufWritable for OptionalEntityId {
|
||||
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
|
||||
(self.0 + 1).var_write_into(buf)?;
|
||||
Ok(())
|
||||
match self.0 {
|
||||
Some(id) => (id + 1).var_write_into(buf),
|
||||
None => 0u32.var_write_into(buf),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue