1use std::fmt::Debug;
2
3use azalea_buf::AzBuf;
4use azalea_core::position::{BlockPos, Vec3};
5use azalea_registry::{Block, DebugSubscription, GameEvent, PointOfInterestKind};
6
7macro_rules! debug_subscription_enum {
10 ($($variant:ident($ty:ty),)*) => {
11 #[derive(Clone, Debug, AzBuf, PartialEq)]
12 pub enum DebugSubscriptionEvent {
13 $( $variant($ty), )*
14 }
15 #[derive(Clone, Debug, AzBuf, PartialEq)]
16 pub enum DebugSubscriptionUpdate {
17 $( $variant(Option<$ty>), )*
18 }
19
20 impl DebugSubscriptionEvent {
21 pub fn matches_registry_variant(&self, kind: DebugSubscription) -> bool {
22 match kind {
26 $(
27 DebugSubscription::$variant => matches!(self, Self::$variant(_)),
28 )*
29 }
30 }
31 }
32 impl DebugSubscriptionUpdate {
33 pub fn matches_registry_variant(&self, kind: DebugSubscription) -> bool {
34 match kind {
35 $(
36 DebugSubscription::$variant => matches!(self, Self::$variant(_)),
37 )*
38 }
39 }
40 }
41 };
42}
43
44debug_subscription_enum! {
47 DedicatedServerTickTime(()),
48 Bees(DebugBeeInfo),
49 Brains(DebugBrainDump),
50 Breezes(DebugBreezeInfo),
51 GoalSelectors(DebugGoalInfo),
52 EntityPaths(DebugPathInfo),
53 EntityBlockIntersections(DebugEntityBlockIntersection),
54 BeeHives(DebugHiveInfo),
55 Pois(DebugPoiInfo),
56 RedstoneWireOrientations(DebugRedstoneOrientation),
57 VillageSections(()),
58 Raids(Vec<BlockPos>),
59 Structures(Vec<DebugStructureInfo>),
60 GameEventListeners(DebugGameEventListenerInfo),
61 NeighborUpdates(BlockPos),
62 GameEvents(DebugGameEventInfo),
63}
64
65#[derive(Clone, Debug, AzBuf, PartialEq)]
66pub struct DebugBeeInfo {
67 pub hive_pos: Option<BlockPos>,
68 pub flower_pos: Option<BlockPos>,
69 #[var]
70 pub travel_ticks: i32,
71 pub blacklisted_hives: Vec<BlockPos>,
72}
73#[derive(Clone, Debug, AzBuf, PartialEq)]
74pub struct DebugBrainDump {
75 pub name: String,
76 pub profession: String,
77 pub xp: i32,
78 pub health: f32,
79 pub max_health: f32,
80 pub inventory: String,
81 pub wants_golem: bool,
82 pub anger_level: i32,
83 pub activities: Vec<String>,
84 pub behaviors: Vec<String>,
85 pub memories: Vec<String>,
86 pub gossips: Vec<String>,
87 pub pois: Vec<BlockPos>,
88 pub potential_pois: Vec<BlockPos>,
89}
90
91#[derive(Clone, Debug, AzBuf, PartialEq)]
92pub struct DebugBreezeInfo {
93 #[var]
94 pub attack_target: Option<i32>,
95 pub jump_target: Option<BlockPos>,
96}
97
98#[derive(Clone, Debug, AzBuf, PartialEq)]
99pub struct DebugGoalInfo {
100 #[var]
101 pub priority: i32,
102 pub is_running: bool,
103 #[limit(255)]
104 pub name: String,
105}
106
107#[derive(Clone, Debug, AzBuf, PartialEq)]
108pub struct DebugPathInfo {
109 pub path: MinecraftPath,
110 pub max_node_distance: f32,
111}
112
113#[derive(Clone, Copy, Debug, AzBuf, PartialEq)]
114pub enum DebugEntityBlockIntersection {
115 InBlock,
116 InFluid,
117 InAir,
118}
119
120#[derive(Clone, Debug, AzBuf, PartialEq)]
121pub struct DebugHiveInfo {
122 pub kind: Block,
123 #[var]
124 pub occupant_count: i32,
125 #[var]
126 pub honey_level: i32,
127 pub sedated: bool,
128}
129
130#[derive(Clone, Debug, AzBuf, PartialEq)]
131pub struct DebugPoiInfo {
132 pub pos: BlockPos,
133 pub poi_kind: PointOfInterestKind,
134 #[var]
135 pub free_ticket_count: i32,
136}
137
138#[derive(Clone, Debug, AzBuf, PartialEq)]
139pub struct DebugRedstoneOrientation {
140 #[var]
141 pub id: u32,
142}
143
144#[derive(Clone, Debug, AzBuf, PartialEq)]
145pub struct DebugStructureInfo {
146 pub bounding_box: StructureBoundingBox,
147 pub pieces: Vec<StructurePiece>,
148}
149
150#[derive(Clone, Debug, AzBuf, PartialEq)]
151pub struct DebugGameEventListenerInfo {
152 #[var]
153 pub listener_radius: i32,
154}
155
156#[derive(Clone, Debug, AzBuf, PartialEq)]
157pub struct DebugGameEventInfo {
158 pub event: GameEvent,
159 pub pos: Vec3,
160}
161
162#[derive(Clone, Debug, AzBuf, PartialEq)]
163pub struct StructureBoundingBox {
164 pub min: BlockPos,
165 pub max: BlockPos,
166}
167
168#[derive(Clone, Debug, AzBuf, PartialEq)]
169pub struct StructurePiece {
170 pub bounding_box: StructureBoundingBox,
171 pub is_start: bool,
172}
173
174#[derive(Clone, Debug, AzBuf, PartialEq)]
175pub struct MinecraftPath {
176 pub reached: bool,
177 pub next_node_index: i32,
178 pub block_pos: BlockPos,
179 pub nodes: Vec<MinecraftPathNode>,
180 pub debug_data: MinecraftPathDebugData,
181}
182
183#[derive(Clone, Debug, AzBuf, PartialEq)]
184pub struct MinecraftPathNode {
185 pub x: i32,
186 pub y: i32,
187 pub z: i32,
188 pub contents: MinecraftPathNodeContents,
189}
190
191#[derive(Clone, Debug, AzBuf, PartialEq)]
192pub struct MinecraftPathNodeContents {
193 pub walked_distance: f32,
194 pub cost_malus: f32,
195 pub closed: bool,
196 pub kind: MinecraftPathNodeKind,
197 pub f: f32,
198}
199
200#[derive(Clone, Copy, Debug, AzBuf, PartialEq)]
202pub enum MinecraftPathNodeKind {
203 Blocked,
204 Open,
205 Walkable,
206 WalkableDoor,
207 Trapdoor,
208 PowderSnow,
209 DangerPowderSnow,
210 Fence,
211 Lava,
212 Water,
213 WaterBorder,
214 Rail,
215 UnpassableRail,
216 DangerFire,
217 DamageFire,
218 DangerOther,
219 DamageOther,
220 DoorOpen,
221 DoorWoodClosed,
222 DoorIronClosed,
223 Breach,
224 Leaves,
225 StickyHoney,
226 Cocoa,
227 DamageCautious,
228 DangerTrapdoor,
229}
230
231#[derive(Clone, Debug, AzBuf, PartialEq)]
232pub struct MinecraftPathDebugData {
233 pub target_nodes: Vec<MinecraftPathNode>,
234 pub open_set: Vec<MinecraftPathNode>,
235 pub closed_set: Vec<MinecraftPathNode>,
236}