aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-14 19:55:33 -0500
committermat <github@matdoes.dev>2022-05-14 19:55:33 -0500
commit93730a550aed964d122bc08f5353e8eb0c5c9f31 (patch)
treeff7049aa81e152b0c69192434fc5a2c15b8c6b9e /azalea-protocol/src/packets
parent3f77390e2671045ed3ea45f24a9ade151eafe700 (diff)
downloadazalea-drasl-93730a550aed964d122bc08f5353e8eb0c5c9f31.tar.xz
start adding ClientboundLevelParticlesPacket
Diffstat (limited to 'azalea-protocol/src/packets')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_animate_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_chat_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_game_event_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs6
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs17
-rw-r--r--azalea-protocol/src/packets/game/clientbound_light_update_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_info_packet.rs14
-rw-r--r--azalea-protocol/src/packets/game/clientbound_recipe_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs2
-rw-r--r--azalea-protocol/src/packets/game/clientbound_sound_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs12
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs6
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs12
-rwxr-xr-xazalea-protocol/src/packets/game/mod.rs8
-rwxr-xr-xazalea-protocol/src/packets/mod.rs2
15 files changed, 61 insertions, 42 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs
index 84a20381..6ac4bd99 100644
--- a/azalea-protocol/src/packets/game/clientbound_animate_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_animate_packet.rs
@@ -1,4 +1,4 @@
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundAnimatePacket {
@@ -9,7 +9,7 @@ pub struct ClientboundAnimatePacket {
// minecraft actually uses a u8 for this, but a varint still works and makes it
// so i don't have to add a special handler
-#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, Copy, McBuf)]
pub enum AnimationAction {
SwingMainHand = 0,
Hurt = 1,
diff --git a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs
index 3786993a..7a52337e 100644
--- a/azalea-protocol/src/packets/game/clientbound_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_chat_packet.rs
@@ -1,5 +1,5 @@
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use uuid::Uuid;
#[derive(Clone, Debug, GamePacket)]
@@ -9,7 +9,7 @@ pub struct ClientboundChatPacket {
pub sender: Uuid,
}
-#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, Copy, McBuf)]
pub enum ChatType {
Chat = 0,
System = 1,
diff --git a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs
index c3ae2299..faba0a6e 100644
--- a/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_game_event_packet.rs
@@ -1,4 +1,4 @@
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundGameEventPacket {
@@ -6,7 +6,7 @@ pub struct ClientboundGameEventPacket {
pub param: f32,
}
-#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, Copy, McBuf)]
pub enum EventType {
NoRespawnBlockAvailable = 0,
StartRaining = 1,
diff --git a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
index edcb5777..dab36050 100644
--- a/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_chunk_with_light_packet.rs
@@ -1,4 +1,4 @@
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use super::clientbound_light_update_packet::ClientboundLightUpdatePacketData;
@@ -10,7 +10,7 @@ pub struct ClientboundLevelChunkWithLightPacket {
pub light_data: ClientboundLightUpdatePacketData,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct ClientboundLevelChunkPacketData {
pub heightmaps: azalea_nbt::Tag,
// we can't parse the data in azalea-protocol because it dependso on context from other packets
@@ -18,7 +18,7 @@ pub struct ClientboundLevelChunkPacketData {
pub block_entities: Vec<BlockEntity>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct BlockEntity {
pub packed_xz: u8,
pub y: u16,
diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
new file mode 100644
index 00000000..0194d08d
--- /dev/null
+++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
@@ -0,0 +1,17 @@
+use crate::mc_buf::ParticleData;
+use packet_macros::GamePacket;
+
+#[derive(Clone, Debug, GamePacket)]
+pub struct ClientboundLevelParticlesPacket {
+ pub particle_id: u32,
+ pub override_limiter: bool,
+ pub x: f64,
+ pub y: f64,
+ pub z: f64,
+ pub x_dist: f32,
+ pub y_dist: f32,
+ pub z_dist: f32,
+ pub max_speed: f32,
+ pub count: i32,
+ pub data: ParticleData,
+}
diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
index e83d1e87..0c75b356 100644
--- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
@@ -1,5 +1,5 @@
use crate::mc_buf::BitSet;
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundLightUpdatePacket {
@@ -8,7 +8,7 @@ pub struct ClientboundLightUpdatePacket {
pub light_data: ClientboundLightUpdatePacketData,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct ClientboundLightUpdatePacketData {
trust_edges: bool,
sky_y_mask: BitSet,
diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
index 8e7ce4fd..db306ade 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
@@ -1,6 +1,6 @@
use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
use azalea_chat::component::Component;
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use std::io::{Read, Write};
use uuid::Uuid;
@@ -18,14 +18,14 @@ pub enum Action {
RemovePlayer(Vec<RemovePlayer>),
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct PlayerProperty {
name: String,
value: String,
signature: Option<String>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct AddPlayer {
uuid: Uuid,
name: String,
@@ -37,26 +37,26 @@ pub struct AddPlayer {
display_name: Option<Component>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct UpdateGameMode {
uuid: Uuid,
#[var]
gamemode: u32,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct UpdateLatency {
uuid: Uuid,
#[var]
ping: i32,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct UpdateDisplayName {
uuid: Uuid,
display_name: Option<Component>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct RemovePlayer {
uuid: Uuid,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
index fa0d58f0..9a9623ad 100644
--- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
@@ -1,6 +1,6 @@
use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use std::io::{Read, Write};
#[derive(Clone, Debug, GamePacket)]
@@ -11,7 +11,7 @@ pub struct ClientboundRecipePacket {
pub to_highlight: Vec<ResourceLocation>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct RecipeBookSettings {
pub gui_open: bool,
pub filtering_craftable: bool,
diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
index 7f57a126..91d579a8 100644
--- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
@@ -37,7 +37,7 @@ impl McBufWritable for BlockStateWithPosition {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
let data = (self.state as u64) << 12
| ((self.pos.x as u64) << 8 | (self.pos.z as u64) << 4 | (self.pos.y as u64));
- u64::var_write_into(&data, buf);
+ u64::var_write_into(&data, buf)?;
Ok(())
}
}
diff --git a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
index 67e832fe..8094227b 100644
--- a/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_sound_packet.rs
@@ -1,4 +1,4 @@
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundSoundPacket {
@@ -13,7 +13,7 @@ pub struct ClientboundSoundPacket {
pub pitch: f32,
}
-#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, Copy, McBuf)]
pub enum SoundSource {
Master = 0,
Music = 1,
diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
index fe2c226d..0bd18319 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
@@ -1,7 +1,7 @@
use crate::packets::{McBufReadable, McBufWritable};
use azalea_chat::component::Component;
use azalea_core::{resource_location::ResourceLocation, Slot};
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use std::{
collections::HashMap,
io::{Read, Write},
@@ -15,7 +15,7 @@ pub struct ClientboundUpdateAdvancementsPacket {
pub progress: HashMap<ResourceLocation, AdvancementProgress>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct Advancement {
parent_id: Option<ResourceLocation>,
display: Option<DisplayInfo>,
@@ -25,7 +25,7 @@ pub struct Advancement {
// requirements_strategy: RequirementsStrategy.AND
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct DisplayInfo {
pub title: Component,
pub description: Component,
@@ -71,7 +71,7 @@ impl McBufWritable for DisplayFlags {
}
}
-#[derive(Clone, Debug, Copy, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, Copy, McBuf)]
pub enum FrameType {
Task = 0,
Challenge = 1,
@@ -79,12 +79,12 @@ pub enum FrameType {
}
// nothing is written here
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct Criterion {}
pub type AdvancementProgress = HashMap<ResourceLocation, CriterionProgress>;
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct CriterionProgress {
date: Option<u64>,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
index 3d83e6fb..2b382c9f 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
@@ -1,6 +1,6 @@
use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
use azalea_core::resource_location::ResourceLocation;
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use std::io::{Read, Write};
use uuid::Uuid;
@@ -11,14 +11,14 @@ pub struct ClientboundUpdateAttributesPacket {
pub attributes: Vec<AttributeSnapshot>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct AttributeSnapshot {
pub attribute: ResourceLocation,
pub base: f64,
pub modifiers: Vec<Modifier>,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct Modifier {
pub uuid: Uuid,
pub amount: f64,
diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
index 5b4c5cd9..e7756248 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
@@ -1,7 +1,7 @@
use std::io::{Read, Write};
use azalea_core::{resource_location::ResourceLocation, Slot};
-use packet_macros::{GamePacket, McBufReadable, McBufWritable};
+use packet_macros::{GamePacket, McBuf};
use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
@@ -16,7 +16,7 @@ pub struct Recipe {
pub data: RecipeData,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct ShapelessRecipe {
/// Used to group similar recipes together in the recipe book.
/// Tag is present in recipe JSON
@@ -68,7 +68,7 @@ impl McBufReadable for ShapedRecipe {
}
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct CookingRecipe {
group: String,
ingredient: Ingredient,
@@ -77,13 +77,13 @@ pub struct CookingRecipe {
#[var]
cooking_time: u32,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct StoneCuttingRecipe {
group: String,
ingredient: Ingredient,
result: Slot,
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct SmithingRecipe {
base: Ingredient,
addition: Ingredient,
@@ -116,7 +116,7 @@ pub enum RecipeData {
Smithing(SmithingRecipe),
}
-#[derive(Clone, Debug, McBufReadable, McBufWritable)]
+#[derive(Clone, Debug, McBuf)]
pub struct Ingredient {
pub allowed: Vec<Slot>,
}
diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs
index f8ead9d6..883e03aa 100755
--- a/azalea-protocol/src/packets/game/mod.rs
+++ b/azalea-protocol/src/packets/game/mod.rs
@@ -16,6 +16,7 @@ pub mod clientbound_initialize_border_packet;
pub mod clientbound_keep_alive_packet;
pub mod clientbound_level_chunk_with_light_packet;
pub mod clientbound_level_event_packet;
+pub mod clientbound_level_particles_packet;
pub mod clientbound_light_update_packet;
pub mod clientbound_login_packet;
pub mod clientbound_move_entity_pos_packet;
@@ -58,10 +59,10 @@ declare_state_packets!(
0x00: clientbound_add_entity_packet::ClientboundAddEntityPacket,
0x02: clientbound_add_mob_packet::ClientboundAddMobPacket,
0x04: clientbound_add_player_packet::ClientboundAddPlayerPacket,
- 0x6: clientbound_animate_packet::ClientboundAnimatePacket,
- 0xc: clientbound_block_update_packet::ClientboundBlockUpdatePacket,
+ 0x06: clientbound_animate_packet::ClientboundAnimatePacket,
+ 0x0c: clientbound_block_update_packet::ClientboundBlockUpdatePacket,
0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
- 0xf: clientbound_chat_packet::ClientboundChatPacket,
+ 0x0f: clientbound_chat_packet::ClientboundChatPacket,
0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket,
0x14: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket,
0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket,
@@ -72,6 +73,7 @@ declare_state_packets!(
0x21: clientbound_keep_alive_packet::ClientboundKeepAlivePacket,
0x22: clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket,
0x23: clientbound_level_event_packet::ClientboundLevelEventPacket,
+ 0x24: clientbound_level_particles_packet::ClientboundLevelParticlesPacket,
0x25: clientbound_light_update_packet::ClientboundLightUpdatePacket,
0x26: clientbound_login_packet::ClientboundLoginPacket,
0x29: clientbound_move_entity_pos_packet::ClientboundMoveEntityPosPacket,
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs
index a706646d..16e97068 100755
--- a/azalea-protocol/src/packets/mod.rs
+++ b/azalea-protocol/src/packets/mod.rs
@@ -43,7 +43,7 @@ where
fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>;
}
-impl McBufReadable for ConnectionProtocol {
+impl crate::mc_buf::McBufReadable for ConnectionProtocol {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
ConnectionProtocol::from_i32(buf.read_varint()?)
.ok_or_else(|| "Invalid intention".to_string())