1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
use std::fmt::Debug;
use azalea_buf::AzBuf;
use azalea_core::position::{BlockPos, Vec3};
use azalea_registry::builtin::{BlockKind, DebugSubscription, GameEvent, PointOfInterestKind};
// see DebugSubscriptions.java
macro_rules! debug_subscription_enum {
($($variant:ident($ty:ty),)*) => {
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub enum DebugSubscriptionEvent {
$( $variant($ty), )*
}
#[derive(AzBuf, Clone, Debug, 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(AzBuf, Clone, Debug, 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(AzBuf, Clone, Debug, 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(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugBreezeInfo {
#[var]
pub attack_target: Option<i32>,
pub jump_target: Option<BlockPos>,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugGoalInfo {
#[var]
pub priority: i32,
pub is_running: bool,
#[limit(255)]
pub name: String,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugPathInfo {
pub path: MinecraftPath,
pub max_node_distance: f32,
}
#[derive(AzBuf, Clone, Copy, Debug, PartialEq)]
pub enum DebugEntityBlockIntersection {
InBlock,
InFluid,
InAir,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugHiveInfo {
pub kind: BlockKind,
#[var]
pub occupant_count: i32,
#[var]
pub honey_level: i32,
pub sedated: bool,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugPoiInfo {
pub pos: BlockPos,
pub poi_kind: PointOfInterestKind,
#[var]
pub free_ticket_count: i32,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugRedstoneOrientation {
#[var]
pub id: u32,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugStructureInfo {
pub bounding_box: StructureBoundingBox,
pub pieces: Vec<StructurePiece>,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugGameEventListenerInfo {
#[var]
pub listener_radius: i32,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct DebugGameEventInfo {
pub event: GameEvent,
pub pos: Vec3,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct StructureBoundingBox {
pub min: BlockPos,
pub max: BlockPos,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct StructurePiece {
pub bounding_box: StructureBoundingBox,
pub is_start: bool,
}
#[derive(AzBuf, Clone, Debug, 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(AzBuf, Clone, Debug, PartialEq)]
pub struct MinecraftPathNode {
pub x: i32,
pub y: i32,
pub z: i32,
pub contents: MinecraftPathNodeContents,
}
#[derive(AzBuf, Clone, Debug, PartialEq)]
pub struct MinecraftPathNodeContents {
pub walked_distance: f32,
pub cost_malus: f32,
pub closed: bool,
pub kind: MinecraftPathNodeKind,
pub f: f32,
}
// PathType.java
#[derive(AzBuf, Clone, Copy, Debug, 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(AzBuf, Clone, Debug, PartialEq)]
pub struct MinecraftPathDebugData {
pub target_nodes: Vec<MinecraftPathNode>,
pub open_set: Vec<MinecraftPathNode>,
pub closed_set: Vec<MinecraftPathNode>,
}
|