aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-03-14 16:33:03 -0500
committerGitHub <noreply@github.com>2023-03-14 16:33:03 -0500
commit12a9c8ce65b58f0c600fd7b9fc5d454ce228b420 (patch)
tree9bada4164ea12fa533d413c0c7090f4779b519f1 /azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs
parentb792e21d1c2b7dba04d88dba479ed451104a6514 (diff)
downloadazalea-drasl-12a9c8ce65b58f0c600fd7b9fc5d454ce228b420.tar.xz
1.19.4 (#57)
* 23w03a * 23w04a * 23w05a * 23w06a * fix * 23w07a mojang broke their json data generator so some stuff is missing * didn't mean to commit that file here * 1.19.4-pre2 * fix * 1.19.4-pre3 * fix * how did these packets get here * 1.19.4-pre4 * 1.19.4-rc1 * 1.19.4-rc2 * 1.19.4-rc3 * merge main * remove debugging code * 1.19.4
Diffstat (limited to 'azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs
new file mode 100644
index 00000000..93731445
--- /dev/null
+++ b/azalea-protocol/src/packets/game/clientbound_damage_event_packet.rs
@@ -0,0 +1,30 @@
+use std::io::{Cursor, Write};
+
+use azalea_buf::{McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
+use azalea_core::Vec3;
+use azalea_protocol_macros::ClientboundGamePacket;
+
+#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
+pub struct ClientboundDamageEventPacket {
+ #[var]
+ pub entity_id: u32,
+ #[var]
+ pub source_type_id: u32,
+ pub source_cause_id: OptionalEntityId,
+ pub source_direct_id: OptionalEntityId,
+ pub source_position: Option<Vec3>,
+}
+
+#[derive(Clone, Debug)]
+pub struct OptionalEntityId(pub 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))
+ }
+}
+impl McBufWritable for OptionalEntityId {
+ fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ (self.0 + 1).var_write_into(buf)?;
+ Ok(())
+ }
+}