1+ use crate :: dungeon:: dungeon_player:: DungeonPlayer ;
2+ use crate :: dungeon:: items:: ability:: Cooldown ;
3+ use crate :: dungeon:: items:: dungeon_items:: DungeonItem ;
4+ use glam:: IVec3 ;
5+ use indoc:: indoc;
6+ use server:: constants:: Sound ;
7+ use server:: inventory:: item_stack:: ItemStack ;
8+ use server:: network:: binary:: nbt:: NBT ;
9+ use server:: player:: packet_processing:: BlockInteractResult ;
10+ use server:: Player ;
11+
12+ #[ derive( Copy , Clone , Hash , Eq , PartialEq ) ]
13+ pub struct SuperboomTNT ;
14+
15+ impl DungeonItem for SuperboomTNT {
16+
17+ fn on_interact ( & self , player : & mut Player < DungeonPlayer > , block : Option < BlockInteractResult > ) {
18+ if let Some ( block) = block {
19+ if player. item_cooldown ( & SuperboomTNT . into ( ) ) . is_some ( ) {
20+ return ;
21+ }
22+
23+ player. sync_inventory ( ) ;
24+ player. play_sound_at (
25+ Sound :: RandomExplode ,
26+ 1.0 ,
27+ 0.8 ,
28+ block. position . as_dvec3 ( )
29+ ) ;
30+
31+ player. add_item_cooldown ( & SuperboomTNT . into ( ) , Cooldown :: from_ticks ( 10 , true ) )
32+ // get current room, iterate over crypts and walls and explode
33+ }
34+ }
35+
36+ fn on_start_dig ( & self , player : & mut Player < DungeonPlayer > , position : IVec3 ) {
37+ if player. item_cooldown ( & SuperboomTNT . into ( ) ) . is_some ( ) {
38+ return ;
39+ }
40+
41+ player. play_sound_at (
42+ Sound :: RandomExplode ,
43+ 1.0 ,
44+ 0.8 ,
45+ position. as_dvec3 ( )
46+ ) ;
47+
48+ player. add_item_cooldown ( & SuperboomTNT . into ( ) , Cooldown :: from_ticks ( 7 , true ) )
49+ }
50+
51+ fn item_stack ( & self ) -> ItemStack {
52+ ItemStack {
53+ item : 46 ,
54+ stack_size : 64 ,
55+ metadata : 0 ,
56+ tag_compound : Some ( NBT :: with_nodes ( vec ! [
57+ NBT :: compound( "display" , vec![
58+ NBT :: list_from_string( "Lore" , indoc! { r#"
59+ §7Breaks weak walls. Can be used to
60+ §7blow up Crypts in §cThe Catacombs and
61+ §5Crystal Hollows§7.
62+
63+ §9§lRARE
64+ "# } ) ,
65+ NBT :: string( "Name" , "§9Superboom TNT" ) ,
66+ ] ) ,
67+ ] ) ) ,
68+ }
69+ }
70+ }
0 commit comments