diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-09-30 10:56:34 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-30 10:56:34 -0500 |
| commit | 643fcb98c0e6cdc63218dd39960d9053b209d9a6 (patch) | |
| tree | 6bddb7fe39b8fcc3ab3fb2665574533bb227898a /azalea-protocol/src/common | |
| parent | a80d8d1b242430c4a251876fa67bfd26af7a0de9 (diff) | |
| download | azalea-drasl-643fcb98c0e6cdc63218dd39960d9053b209d9a6.tar.xz | |
1.21.9 (#235)
* start updating to 25w33a
* 1.21.9-pre2
* clippy
* cleanup, and fix c_explode and c_player_rotation
* mc update should be in Changed section in the changelog
* 1.21.9
Diffstat (limited to 'azalea-protocol/src/common')
| -rw-r--r-- | azalea-protocol/src/common/debug_subscription.rs | 236 | ||||
| -rw-r--r-- | azalea-protocol/src/common/mod.rs | 1 |
2 files changed, 237 insertions, 0 deletions
diff --git a/azalea-protocol/src/common/debug_subscription.rs b/azalea-protocol/src/common/debug_subscription.rs new file mode 100644 index 00000000..221cd98c --- /dev/null +++ b/azalea-protocol/src/common/debug_subscription.rs @@ -0,0 +1,236 @@ +use std::fmt::Debug; + +use azalea_buf::AzBuf; +use azalea_core::position::{BlockPos, Vec3}; +use azalea_registry::{Block, DebugSubscription, GameEvent, PointOfInterestKind}; + +// see DebugSubscriptions.java + +macro_rules! debug_subscription_enum { + ($($variant:ident($ty:ty),)*) => { + #[derive(Clone, Debug, AzBuf, PartialEq)] + pub enum DebugSubscriptionEvent { + $( $variant($ty), )* + } + #[derive(Clone, Debug, AzBuf, PartialEq)] + pub enum DebugSubscriptionUpdate { + $( $variant(Option<$ty>), )* + } + + impl DebugSubscriptionEvent { + pub fn matches_registry_variant(&self, kind: DebugSubscription) -> bool { + // this mostly exists to cause a compile error whenever the + // DebugSubscription registry is updated, since we need to + // update the debug_subscription_enum block manually + match kind { + $( + DebugSubscription::$variant => matches!(self, Self::$variant(_)), + )* + } + } + } + impl DebugSubscriptionUpdate { + pub fn matches_registry_variant(&self, kind: DebugSubscription) -> bool { + match kind { + $( + DebugSubscription::$variant => matches!(self, Self::$variant(_)), + )* + } + } + } + }; +} + +// we need the values to exist as required and optional, so we create two nearly +// identical enums with a macro +debug_subscription_enum! { + DedicatedServerTickTime(()), + Bees(DebugBeeInfo), + Brains(DebugBrainDump), + Breezes(DebugBreezeInfo), + GoalSelectors(DebugGoalInfo), + EntityPaths(DebugPathInfo), + EntityBlockIntersections(DebugEntityBlockIntersection), + BeeHives(DebugHiveInfo), + Pois(DebugPoiInfo), + RedstoneWireOrientations(DebugRedstoneOrientation), + VillageSections(()), + Raids(Vec<BlockPos>), + Structures(Vec<DebugStructureInfo>), + GameEventListeners(DebugGameEventListenerInfo), + NeighborUpdates(BlockPos), + GameEvents(DebugGameEventInfo), +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugBeeInfo { + pub hive_pos: Option<BlockPos>, + pub flower_pos: Option<BlockPos>, + #[var] + pub travel_ticks: i32, + pub blacklisted_hives: Vec<BlockPos>, +} +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugBrainDump { + pub name: String, + pub profession: String, + pub xp: i32, + pub health: f32, + pub max_health: f32, + pub inventory: String, + pub wants_golem: bool, + pub anger_level: i32, + pub activities: Vec<String>, + pub behaviors: Vec<String>, + pub memories: Vec<String>, + pub gossips: Vec<String>, + pub pois: Vec<BlockPos>, + pub potential_pois: Vec<BlockPos>, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugBreezeInfo { + #[var] + pub attack_target: Option<i32>, + pub jump_target: Option<BlockPos>, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugGoalInfo { + #[var] + pub priority: i32, + pub is_running: bool, + #[limit(255)] + pub name: String, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugPathInfo { + pub path: MinecraftPath, + pub max_node_distance: f32, +} + +#[derive(Clone, Copy, Debug, AzBuf, PartialEq)] +pub enum DebugEntityBlockIntersection { + InBlock, + InFluid, + InAir, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugHiveInfo { + pub kind: Block, + #[var] + pub occupant_count: i32, + #[var] + pub honey_level: i32, + pub sedated: bool, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugPoiInfo { + pub pos: BlockPos, + pub poi_kind: PointOfInterestKind, + #[var] + pub free_ticket_count: i32, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugRedstoneOrientation { + #[var] + pub id: u32, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugStructureInfo { + pub bounding_box: StructureBoundingBox, + pub pieces: Vec<StructurePiece>, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugGameEventListenerInfo { + #[var] + pub listener_radius: i32, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct DebugGameEventInfo { + pub event: GameEvent, + pub pos: Vec3, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct StructureBoundingBox { + pub min: BlockPos, + pub max: BlockPos, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct StructurePiece { + pub bounding_box: StructureBoundingBox, + pub is_start: bool, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct MinecraftPath { + pub reached: bool, + pub next_node_index: i32, + pub block_pos: BlockPos, + pub nodes: Vec<MinecraftPathNode>, + pub debug_data: MinecraftPathDebugData, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct MinecraftPathNode { + pub x: i32, + pub y: i32, + pub z: i32, + pub contents: MinecraftPathNodeContents, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct MinecraftPathNodeContents { + pub walked_distance: f32, + pub cost_malus: f32, + pub closed: bool, + pub kind: MinecraftPathNodeKind, + pub f: f32, +} + +// PathType.java +#[derive(Clone, Copy, Debug, AzBuf, PartialEq)] +pub enum MinecraftPathNodeKind { + Blocked, + Open, + Walkable, + WalkableDoor, + Trapdoor, + PowderSnow, + DangerPowderSnow, + Fence, + Lava, + Water, + WaterBorder, + Rail, + UnpassableRail, + DangerFire, + DamageFire, + DangerOther, + DamageOther, + DoorOpen, + DoorWoodClosed, + DoorIronClosed, + Breach, + Leaves, + StickyHoney, + Cocoa, + DamageCautious, + DangerTrapdoor, +} + +#[derive(Clone, Debug, AzBuf, PartialEq)] +pub struct MinecraftPathDebugData { + pub target_nodes: Vec<MinecraftPathNode>, + pub open_set: Vec<MinecraftPathNode>, + pub closed_set: Vec<MinecraftPathNode>, +} diff --git a/azalea-protocol/src/common/mod.rs b/azalea-protocol/src/common/mod.rs index f666fc8b..c5da374a 100644 --- a/azalea-protocol/src/common/mod.rs +++ b/azalea-protocol/src/common/mod.rs @@ -1,6 +1,7 @@ //! Some serializable data types that are used by several packets. pub mod client_information; +pub mod debug_subscription; pub mod movements; pub mod recipe; pub mod server_links; |
