11use crate :: block:: block_parameter:: Axis ;
22use crate :: block:: blocks:: Blocks ;
3+ use crate :: block:: rotatable:: Rotatable ;
34use crate :: dungeon:: door:: door_entity:: DoorEntityImpl ;
45use crate :: dungeon:: dungeon:: Dungeon ;
5- use crate :: types:: block_position:: BlockPos ;
66use crate :: utils:: seeded_rng:: seeded_rng;
77use crate :: world:: chunk:: chunk_grid:: ChunkGrid ;
88use crate :: world:: world:: World ;
9- use glam:: DVec3 ;
9+ use glam:: { ivec3 , DVec3 , IVec3 } ;
1010use rand:: prelude:: IndexedRandom ;
1111use std:: collections:: HashMap ;
1212
@@ -24,8 +24,8 @@ pub struct Door {
2424 pub axis : Axis ,
2525 door_type : DoorType ,
2626
27- inner_start : BlockPos ,
28- inner_end : BlockPos ,
27+ inner_start : IVec3 ,
28+ inner_end : IVec3 ,
2929
3030 pub is_open : bool ,
3131}
@@ -39,8 +39,8 @@ impl Door {
3939 axis,
4040 is_open : door_type == DoorType :: Normal ,
4141 door_type,
42- inner_start : BlockPos :: new ( x - 1 , 69 , z - 1 ) ,
43- inner_end : BlockPos :: new ( x + 1 , 72 , z + 1 ) ,
42+ inner_start : ivec3 ( x - 1 , 69 , z - 1 ) ,
43+ inner_end : ivec3 ( x + 1 , 72 , z + 1 ) ,
4444 }
4545 }
4646
@@ -71,21 +71,21 @@ impl Door {
7171 // Doors have a thick bedrock floor usually
7272 chunk_grid. fill_blocks (
7373 Blocks :: Bedrock ,
74- BlockPos :: new ( self . x - dx, 67 , self . z - dz) ,
75- BlockPos :: new ( self . x + dx, 66 , self . z + dz) ,
74+ ivec3 ( self . x - dx, 67 , self . z - dz) ,
75+ ivec3 ( self . x + dx, 66 , self . z + dz) ,
7676 ) ;
7777
7878 // Might need to replace with a random palette of cobble, stone, gravel etc if we want to mimic hypixel FULLY, but this works fine.
7979 chunk_grid. fill_blocks (
8080 Blocks :: Stone { variant : 0 } ,
81- BlockPos :: new ( self . x - ( dz - 2 ) * 2 , 68 , self . z - ( dx - 2 ) * 2 ) ,
82- BlockPos :: new ( self . x + ( dz - 2 ) * 2 , 68 , self . z + ( dx - 2 ) * 2 ) ,
81+ ivec3 ( self . x - ( dz - 2 ) * 2 , 68 , self . z - ( dx - 2 ) * 2 ) ,
82+ ivec3 ( self . x + ( dz - 2 ) * 2 , 68 , self . z + ( dx - 2 ) * 2 ) ,
8383 ) ;
8484
8585 chunk_grid. fill_blocks (
8686 Blocks :: Air ,
87- BlockPos :: new ( self . x - dx, 69 , self . z - dz) ,
88- BlockPos :: new ( self . x + dx, 73 , self . z + dz) ,
87+ ivec3 ( self . x - dx, 69 , self . z - dz) ,
88+ ivec3 ( self . x + dx, 73 , self . z + dz) ,
8989 ) ;
9090
9191 // Pretty much just to get a normal self from a wither one,
@@ -105,7 +105,7 @@ impl Door {
105105 let y = ( index / ( 5 * 5 ) ) as i32 ;
106106 let z = ( ( index / 5 ) % 5 ) as i32 ;
107107
108- let bp = BlockPos :: new ( x - 2 , y, z - 2 ) . rotate ( self_direction) ;
108+ let bp = ivec3 ( x - 2 , y, z - 2 ) . rotate ( self_direction) ;
109109
110110 let mut block_to_place = block. clone ( ) ;
111111 block_to_place. rotate ( self_direction) ;
@@ -114,8 +114,8 @@ impl Door {
114114
115115 chunk_grid. fill_blocks (
116116 self . get_block ( ) ,
117- BlockPos :: new ( self . x - 1 , 69 , self . z - 1 ) ,
118- BlockPos :: new ( self . x + 1 , 72 , self . z + 1 ) ,
117+ ivec3 ( self . x - 1 , 69 , self . z - 1 ) ,
118+ ivec3 ( self . x + 1 , 72 , self . z + 1 ) ,
119119 ) ;
120120 }
121121
@@ -149,8 +149,8 @@ impl Door {
149149
150150 world. chunk_grid . fill_blocks (
151151 Blocks :: Barrier ,
152- BlockPos :: new ( self . x - 1 , 69 , self . z - 1 ) ,
153- BlockPos :: new ( self . x + 1 , 72 , self . z + 1 ) ,
152+ ivec3 ( self . x - 1 , 69 , self . z - 1 ) ,
153+ ivec3 ( self . x + 1 , 72 , self . z + 1 ) ,
154154 ) ;
155155 // door entity gets rid of blocks when it disappears
156156 world. spawn_entity (
@@ -167,7 +167,7 @@ impl Door {
167167 }
168168
169169 // inner bit of door, blocks abilities
170- pub fn contains ( & self , block_pos : & BlockPos ) -> bool {
170+ pub fn contains ( & self , block_pos : & IVec3 ) -> bool {
171171 let ( x , y , z) = ( block_pos. x , block_pos. y , block_pos. z ) ;
172172 ( x >= self . inner_start . x && x <= self . inner_end . x ) &&
173173 ( y >= self . inner_start . y && y <= self . inner_end . y ) &&
0 commit comments