basalt-api 0.2.1

Public plugin API for the Basalt Minecraft server: traits, components, events, and the plugin registration system
Documentation
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
//! Container events: open/close lifecycle, clicks, drags, block entities.

use crate::components::BlockPosition;
use crate::container::{ContainerBacking, InventoryType};
use crate::world::block_entity::BlockEntity;
use basalt_types::Slot;

// ---------------------------------------------------------------------------
// Helper enums
// ---------------------------------------------------------------------------

/// Why a container window is closing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CloseReason {
    /// Player pressed E / ESC.
    Manual,
    /// Player disconnected from the server.
    Disconnect,
    /// Server-initiated close (e.g., admin command).
    ForceClose,
}

/// Categorises which slot was clicked, independent of window type.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WindowSlotKind {
    /// Crafting output slot (in crafting table or player inventory 2x2).
    CraftOutput,
    /// Crafting grid input slot.
    CraftGrid,
    /// Armor slot.
    Armor,
    /// Main player inventory slot (rows under hotbar).
    MainInventory,
    /// Hotbar slot.
    Hotbar,
    /// Offhand slot.
    Offhand,
    /// Container slot (chest slot, hopper slot, etc.).
    Container,
}

/// Type of drag operation (paint mode).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DragType {
    /// Left-click drag: distribute cursor items evenly across slots.
    LeftDrag,
    /// Right-click drag: place 1 item per slot.
    RightDrag,
    /// Middle-click drag: creative fill.
    MiddleDrag,
}

/// Mirror of server's click action that plugins can safely consume.
///
/// Excludes transient click phases (DropCursor, StartDrag, AddDragSlot,
/// EndDrag) which are internal details of the server's click processing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ContainerClickType {
    /// Normal left click on a slot.
    LeftClick,
    /// Normal right click on a slot.
    RightClick,
    /// Shift-click (quick-move).
    ShiftClick,
    /// Double-click (collect matching items).
    DoubleClick,
    /// Q-key drop from a slot.
    DropSlot {
        /// When true the entire stack is dropped (Ctrl+Q).
        drop_all: bool,
    },
    /// Number key swap with hotbar slot (0-8).
    HotbarSwap {
        /// Hotbar slot index (0-8).
        hotbar: u8,
    },
    /// Swap with offhand slot (F key).
    OffhandSwap,
}

pub use crate::world::block_entity::BlockEntityKind;

// ---------------------------------------------------------------------------
// Container lifecycle events
// ---------------------------------------------------------------------------

/// Fires BEFORE a container window opens.
///
/// Cancellable -- plugins can deny the open (e.g., permission checks).
/// Fires during the Validate stage of the game bus.
#[derive(Debug, Clone)]
pub struct ContainerOpenRequestEvent {
    /// The inventory type being requested.
    pub inventory_type: InventoryType,
    /// How the container is backed (block or virtual).
    pub backing: ContainerBacking,
    /// Title that will be shown to the player.
    pub title: String,
    /// Whether the event has been cancelled.
    pub cancelled: bool,
}
crate::game_cancellable_event!(ContainerOpenRequestEvent);

/// Fires AFTER a container window has been opened for a player.
///
/// Non-cancellable. Fires during the Post stage.
#[derive(Debug, Clone)]
pub struct ContainerOpenedEvent {
    /// Protocol window ID assigned at open time (1-127).
    pub window_id: u8,
    /// The inventory type that was opened.
    pub inventory_type: InventoryType,
    /// How the container is backed.
    pub backing: ContainerBacking,
    /// Number of players viewing the same block-backed container,
    /// **including** the player who just opened it. Always at least 1
    /// for `Block` backings, 0 for `Virtual` backings (each virtual
    /// container is per-player).
    ///
    /// Used by `ContainerPlugin` to broadcast the chest-lid open
    /// animation with the right viewer count.
    pub viewer_count: u32,
}
crate::game_event!(ContainerOpenedEvent);

/// Fires BEFORE the `OpenContainer` component is removed from the player.
///
/// Non-cancellable. Fires during the Post stage.
#[derive(Debug, Clone)]
pub struct ContainerClosedEvent {
    /// Window ID that is being closed.
    pub window_id: u8,
    /// The inventory type.
    pub inventory_type: InventoryType,
    /// How the container was backed.
    pub backing: ContainerBacking,
    /// Why the container is closing.
    pub reason: CloseReason,
    /// Number of remaining viewers on the same block-backed container
    /// **excluding** the closing player. 0 for `Virtual` backings.
    ///
    /// Used by `ContainerPlugin` to broadcast the chest-lid close
    /// animation with the right remaining-viewer count (action
    /// param 0 closes the lid completely).
    pub viewer_count: u32,
    /// Snapshot of the player's `CraftingGrid` slots at the moment of
    /// close, populated **only** when `inventory_type ==
    /// InventoryType::Crafting` (3x3 crafting table). The server has
    /// already reset the grid to 2x2 by the time this event fires —
    /// plugins use the snapshot to spawn dropped items.
    ///
    /// `None` for any non-crafting close.
    pub crafting_grid_state: Option<[Slot; 9]>,
}
crate::game_event!(ContainerClosedEvent);

// ---------------------------------------------------------------------------
// Click / drag events
// ---------------------------------------------------------------------------

/// Fires BEFORE a click inside an open container is applied.
///
/// Cancellable -- plugins use this to implement GUI menus where
/// slots act as buttons. Fires during the Validate stage.
///
/// Only fires when a container is open (NOT for player inventory
/// clicks with no open container).
#[derive(Debug, Clone)]
pub struct ContainerClickEvent {
    /// Window ID of the open container.
    pub window_id: u8,
    /// How the container is backed.
    pub backing: ContainerBacking,
    /// Protocol slot index that was clicked.
    pub slot_index: i16,
    /// Logical categorisation of the clicked slot.
    pub window_slot_kind: WindowSlotKind,
    /// Type of click action (left, right, shift, etc.).
    pub click_type: ContainerClickType,
    /// Cursor item state immediately before the click.
    pub cursor_before: Slot,
    /// Whether the event has been cancelled.
    pub cancelled: bool,
}
crate::game_cancellable_event!(ContainerClickEvent);

/// Fires BEFORE a drag (paint mode) distribution is applied.
///
/// Cancellable -- plugins can prevent drag within GUIs.
/// Fires during the Validate stage.
#[derive(Debug, Clone)]
pub struct ContainerDragEvent {
    /// Window ID of the open container.
    pub window_id: u8,
    /// How the container is backed.
    pub backing: ContainerBacking,
    /// Slots affected by the drag (protocol slot index + planned result).
    pub affected_slots: Vec<(i16, Slot)>,
    /// Drag type (left/right/middle).
    pub drag_type: DragType,
    /// Cursor item before distribution.
    pub cursor: Slot,
    /// Whether the event has been cancelled.
    pub cancelled: bool,
}
crate::game_cancellable_event!(ContainerDragEvent);

/// Fires AFTER a container slot has changed.
///
/// Non-cancellable. Fires during the Post stage, once per changed
/// slot. Only fires for [`WindowSlotKind::Container`] -- not for craft
/// grid / inventory slots inside a container window.
#[derive(Debug, Clone)]
pub struct ContainerSlotChangedEvent {
    /// Window ID of the container.
    pub window_id: u8,
    /// How the container is backed.
    pub backing: ContainerBacking,
    /// Protocol slot index that changed.
    pub slot_index: i16,
    /// Slot state before the change.
    pub old: Slot,
    /// Slot state after the change.
    pub new: Slot,
}
crate::game_event!(ContainerSlotChangedEvent);

// ---------------------------------------------------------------------------
// Block entity events
// ---------------------------------------------------------------------------

/// Fires AFTER a block entity is created at a position that had none.
///
/// Non-cancellable. Fires during the Post stage.
#[derive(Debug, Clone)]
pub struct BlockEntityCreatedEvent {
    /// World position of the new block entity.
    pub position: BlockPosition,
    /// Kind of block entity that was created.
    pub kind: BlockEntityKind,
}
crate::game_event!(BlockEntityCreatedEvent);

/// Fires AFTER a block entity's data is modified.
///
/// Non-cancellable. Fires during the Post stage. Triggered by
/// slot writes, tick processing, or explicit replacements.
#[derive(Debug, Clone)]
pub struct BlockEntityModifiedEvent {
    /// World position of the block entity.
    pub position: BlockPosition,
    /// Kind of block entity that was modified.
    pub kind: BlockEntityKind,
}
crate::game_event!(BlockEntityModifiedEvent);

/// Fires AFTER a block entity is removed from the world.
///
/// Non-cancellable. Fires during the Post stage. Carries the last
/// state so plugins can drop contents, backup data, etc.
#[derive(Debug, Clone)]
pub struct BlockEntityDestroyedEvent {
    /// World position of the destroyed block entity.
    pub position: BlockPosition,
    /// Kind of block entity that was destroyed.
    pub kind: BlockEntityKind,
    /// Block entity state immediately before destruction.
    pub last_state: BlockEntity,
}
crate::game_event!(BlockEntityDestroyedEvent);

#[cfg(test)]
mod tests {
    use crate::events::{BusKind, Event, EventRouting};

    use super::*;

    // -- Helper enum construction and equality --------------------------------

    #[test]
    fn close_reason_variants() {
        assert_eq!(CloseReason::Manual, CloseReason::Manual);
        assert_eq!(CloseReason::Disconnect, CloseReason::Disconnect);
        assert_eq!(CloseReason::ForceClose, CloseReason::ForceClose);
        assert_ne!(CloseReason::Manual, CloseReason::Disconnect);
    }

    #[test]
    fn window_slot_kind_variants() {
        let variants = [
            WindowSlotKind::CraftOutput,
            WindowSlotKind::CraftGrid,
            WindowSlotKind::Armor,
            WindowSlotKind::MainInventory,
            WindowSlotKind::Hotbar,
            WindowSlotKind::Offhand,
            WindowSlotKind::Container,
        ];
        for (i, a) in variants.iter().enumerate() {
            assert_eq!(a, a, "variant should equal itself");
            for b in variants.iter().skip(i + 1) {
                assert_ne!(a, b, "distinct variants should differ");
            }
        }
    }

    #[test]
    fn drag_type_variants() {
        assert_eq!(DragType::LeftDrag, DragType::LeftDrag);
        assert_eq!(DragType::RightDrag, DragType::RightDrag);
        assert_eq!(DragType::MiddleDrag, DragType::MiddleDrag);
        assert_ne!(DragType::LeftDrag, DragType::RightDrag);
    }

    #[test]
    fn container_click_type_variants() {
        assert_eq!(ContainerClickType::LeftClick, ContainerClickType::LeftClick);
        assert_eq!(
            ContainerClickType::RightClick,
            ContainerClickType::RightClick
        );
        assert_eq!(
            ContainerClickType::ShiftClick,
            ContainerClickType::ShiftClick
        );
        assert_eq!(
            ContainerClickType::DoubleClick,
            ContainerClickType::DoubleClick
        );
        assert_eq!(
            ContainerClickType::DropSlot { drop_all: true },
            ContainerClickType::DropSlot { drop_all: true }
        );
        assert_ne!(
            ContainerClickType::DropSlot { drop_all: false },
            ContainerClickType::DropSlot { drop_all: true }
        );
        assert_eq!(
            ContainerClickType::HotbarSwap { hotbar: 3 },
            ContainerClickType::HotbarSwap { hotbar: 3 }
        );
        assert_ne!(
            ContainerClickType::HotbarSwap { hotbar: 0 },
            ContainerClickType::HotbarSwap { hotbar: 1 }
        );
        assert_eq!(
            ContainerClickType::OffhandSwap,
            ContainerClickType::OffhandSwap
        );
    }

    #[test]
    fn block_entity_kind_variants() {
        assert_eq!(BlockEntityKind::Chest, BlockEntityKind::Chest);
    }

    // -- Container lifecycle events -------------------------------------------

    #[test]
    fn container_open_request_cancellation() {
        let mut event = ContainerOpenRequestEvent {
            inventory_type: InventoryType::Generic9x3,
            backing: ContainerBacking::Virtual,
            title: "Test".to_string(),
            cancelled: false,
        };
        assert!(!event.is_cancelled());
        event.cancel();
        assert!(event.is_cancelled());
    }

    #[test]
    fn container_opened_construction() {
        let event = ContainerOpenedEvent {
            window_id: 1,
            inventory_type: InventoryType::Generic9x3,
            backing: ContainerBacking::Block {
                position: BlockPosition { x: 5, y: 64, z: 3 },
            },
            viewer_count: 1,
        };
        assert_eq!(event.window_id, 1);
        assert_eq!(event.inventory_type, InventoryType::Generic9x3);
        assert_eq!(event.viewer_count, 1);
    }

    #[test]
    fn container_opened_not_cancellable() {
        let mut event = ContainerOpenedEvent {
            window_id: 1,
            inventory_type: InventoryType::Generic9x3,
            backing: ContainerBacking::Virtual,
            viewer_count: 0,
        };
        event.cancel(); // no-op
        assert!(!event.is_cancelled());
    }

    #[test]
    fn container_closed_construction() {
        let event = ContainerClosedEvent {
            window_id: 2,
            inventory_type: InventoryType::Hopper,
            backing: ContainerBacking::Block {
                position: BlockPosition {
                    x: 10,
                    y: 32,
                    z: -5,
                },
            },
            reason: CloseReason::Manual,
            viewer_count: 0,
            crafting_grid_state: None,
        };
        assert_eq!(event.window_id, 2);
        assert_eq!(event.reason, CloseReason::Manual);
    }

    #[test]
    fn container_closed_not_cancellable() {
        let mut event = ContainerClosedEvent {
            window_id: 1,
            inventory_type: InventoryType::Generic9x3,
            backing: ContainerBacking::Virtual,
            reason: CloseReason::Disconnect,
            viewer_count: 0,
            crafting_grid_state: None,
        };
        event.cancel();
        assert!(!event.is_cancelled());
    }

    // -- Click / drag events --------------------------------------------------

    #[test]
    fn container_click_cancellation() {
        let mut event = ContainerClickEvent {
            window_id: 1,
            backing: ContainerBacking::Virtual,
            slot_index: 5,
            window_slot_kind: WindowSlotKind::Container,
            click_type: ContainerClickType::LeftClick,
            cursor_before: Slot::empty(),
            cancelled: false,
        };
        assert!(!event.is_cancelled());
        event.cancel();
        assert!(event.is_cancelled());
    }

    #[test]
    fn container_click_field_access() {
        let event = ContainerClickEvent {
            window_id: 3,
            backing: ContainerBacking::Block {
                position: BlockPosition { x: 0, y: 64, z: 0 },
            },
            slot_index: 12,
            window_slot_kind: WindowSlotKind::Hotbar,
            click_type: ContainerClickType::HotbarSwap { hotbar: 2 },
            cursor_before: Slot::new(1, 32),
            cancelled: false,
        };
        assert_eq!(event.slot_index, 12);
        assert_eq!(event.window_slot_kind, WindowSlotKind::Hotbar);
        assert_eq!(
            event.click_type,
            ContainerClickType::HotbarSwap { hotbar: 2 }
        );
    }

    #[test]
    fn container_drag_cancellation() {
        let mut event = ContainerDragEvent {
            window_id: 1,
            backing: ContainerBacking::Virtual,
            affected_slots: vec![(0, Slot::new(1, 16)), (1, Slot::new(1, 16))],
            drag_type: DragType::LeftDrag,
            cursor: Slot::new(1, 32),
            cancelled: false,
        };
        assert!(!event.is_cancelled());
        event.cancel();
        assert!(event.is_cancelled());
    }

    #[test]
    fn container_drag_field_access() {
        let event = ContainerDragEvent {
            window_id: 2,
            backing: ContainerBacking::Virtual,
            affected_slots: vec![(5, Slot::new(3, 1))],
            drag_type: DragType::RightDrag,
            cursor: Slot::new(3, 5),
            cancelled: false,
        };
        assert_eq!(event.affected_slots.len(), 1);
        assert_eq!(event.drag_type, DragType::RightDrag);
    }

    #[test]
    fn container_slot_changed_construction() {
        let event = ContainerSlotChangedEvent {
            window_id: 1,
            backing: ContainerBacking::Block {
                position: BlockPosition { x: 5, y: 64, z: 3 },
            },
            slot_index: 7,
            old: Slot::empty(),
            new: Slot::new(1, 1),
        };
        assert_eq!(event.slot_index, 7);
    }

    #[test]
    fn container_slot_changed_not_cancellable() {
        let mut event = ContainerSlotChangedEvent {
            window_id: 1,
            backing: ContainerBacking::Virtual,
            slot_index: 0,
            old: Slot::empty(),
            new: Slot::empty(),
        };
        event.cancel();
        assert!(!event.is_cancelled());
    }

    // -- Block entity events --------------------------------------------------

    #[test]
    fn block_entity_created_construction() {
        let event = BlockEntityCreatedEvent {
            position: BlockPosition { x: 5, y: 64, z: 3 },
            kind: BlockEntityKind::Chest,
        };
        assert_eq!(event.position, BlockPosition { x: 5, y: 64, z: 3 });
        assert_eq!(event.kind, BlockEntityKind::Chest);
    }

    #[test]
    fn block_entity_created_not_cancellable() {
        let mut event = BlockEntityCreatedEvent {
            position: BlockPosition { x: 0, y: 0, z: 0 },
            kind: BlockEntityKind::Chest,
        };
        event.cancel();
        assert!(!event.is_cancelled());
    }

    #[test]
    fn block_entity_modified_construction() {
        let event = BlockEntityModifiedEvent {
            position: BlockPosition {
                x: -10,
                y: 32,
                z: 100,
            },
            kind: BlockEntityKind::Chest,
        };
        assert_eq!(event.kind, BlockEntityKind::Chest);
    }

    #[test]
    fn block_entity_modified_not_cancellable() {
        let mut event = BlockEntityModifiedEvent {
            position: BlockPosition { x: 0, y: 0, z: 0 },
            kind: BlockEntityKind::Chest,
        };
        event.cancel();
        assert!(!event.is_cancelled());
    }

    #[test]
    fn block_entity_destroyed_carries_last_state() {
        let be = BlockEntity::empty_chest();
        let event = BlockEntityDestroyedEvent {
            position: BlockPosition {
                x: 100,
                y: 64,
                z: -50,
            },
            kind: BlockEntityKind::Chest,
            last_state: be,
        };
        match &event.last_state {
            BlockEntity::Chest { slots } => {
                assert_eq!(slots.len(), 27);
            }
        }
    }

    #[test]
    fn block_entity_destroyed_not_cancellable() {
        let mut event = BlockEntityDestroyedEvent {
            position: BlockPosition { x: 0, y: 0, z: 0 },
            kind: BlockEntityKind::Chest,
            last_state: BlockEntity::empty_chest(),
        };
        event.cancel();
        assert!(!event.is_cancelled());
    }

    // -- Bus kind routing -----------------------------------------------------

    #[test]
    fn all_events_route_to_game_bus() {
        assert_eq!(ContainerOpenRequestEvent::BUS, BusKind::Game);
        assert_eq!(ContainerOpenedEvent::BUS, BusKind::Game);
        assert_eq!(ContainerClosedEvent::BUS, BusKind::Game);
        assert_eq!(ContainerClickEvent::BUS, BusKind::Game);
        assert_eq!(ContainerDragEvent::BUS, BusKind::Game);
        assert_eq!(ContainerSlotChangedEvent::BUS, BusKind::Game);
        assert_eq!(BlockEntityCreatedEvent::BUS, BusKind::Game);
        assert_eq!(BlockEntityModifiedEvent::BUS, BusKind::Game);
        assert_eq!(BlockEntityDestroyedEvent::BUS, BusKind::Game);
    }

    #[test]
    fn bus_kind_method_matches_const() {
        let events_game: Vec<Box<dyn Event>> = vec![
            Box::new(ContainerOpenRequestEvent {
                inventory_type: InventoryType::Generic9x3,
                backing: ContainerBacking::Virtual,
                title: String::new(),
                cancelled: false,
            }),
            Box::new(ContainerOpenedEvent {
                window_id: 1,
                inventory_type: InventoryType::Generic9x3,
                backing: ContainerBacking::Virtual,
                viewer_count: 0,
            }),
            Box::new(ContainerClosedEvent {
                window_id: 1,
                inventory_type: InventoryType::Generic9x3,
                backing: ContainerBacking::Virtual,
                reason: CloseReason::Manual,
                viewer_count: 0,
                crafting_grid_state: None,
            }),
            Box::new(ContainerClickEvent {
                window_id: 1,
                backing: ContainerBacking::Virtual,
                slot_index: 0,
                window_slot_kind: WindowSlotKind::Container,
                click_type: ContainerClickType::LeftClick,
                cursor_before: Slot::empty(),
                cancelled: false,
            }),
            Box::new(ContainerDragEvent {
                window_id: 1,
                backing: ContainerBacking::Virtual,
                affected_slots: vec![],
                drag_type: DragType::LeftDrag,
                cursor: Slot::empty(),
                cancelled: false,
            }),
            Box::new(ContainerSlotChangedEvent {
                window_id: 1,
                backing: ContainerBacking::Virtual,
                slot_index: 0,
                old: Slot::empty(),
                new: Slot::empty(),
            }),
            Box::new(BlockEntityCreatedEvent {
                position: BlockPosition { x: 0, y: 0, z: 0 },
                kind: BlockEntityKind::Chest,
            }),
            Box::new(BlockEntityModifiedEvent {
                position: BlockPosition { x: 0, y: 0, z: 0 },
                kind: BlockEntityKind::Chest,
            }),
            Box::new(BlockEntityDestroyedEvent {
                position: BlockPosition { x: 0, y: 0, z: 0 },
                kind: BlockEntityKind::Chest,
                last_state: BlockEntity::empty_chest(),
            }),
        ];
        for event in &events_game {
            assert_eq!(event.bus_kind(), BusKind::Game);
        }
    }
}