@@ -61,7 +61,7 @@ public function testThrow(): void
6161 $ this ->assertGreaterThan ($ bounceEvent ->position ->z , $ landEvent ->position ->z );
6262 $ this ->assertSame ($ floorY , $ bounceEvent ->position ->y );
6363 $ this ->assertSame ($ floorY , $ landEvent ->position ->y );
64- $ this ->assertPositionSame (new Point (152 , $ floorY , 720 ), $ landEvent ->position );
64+ $ this ->assertPositionSame (new Point (153 , $ floorY , 707 ), $ landEvent ->position );
6565 }
6666
6767 public function testThrowRun (): void
@@ -108,7 +108,7 @@ function (Player $p) {
108108 $ this ->assertGreaterThan ($ bounceEvent ->position ->z , $ landEvent ->position ->z );
109109 $ this ->assertSame ($ floorY , $ bounceEvent ->position ->y );
110110 $ this ->assertSame ($ floorY , $ landEvent ->position ->y );
111- $ this ->assertPositionSame (new Point (220 , $ floorY , 1022 ), $ landEvent ->position );
111+ $ this ->assertPositionSame (new Point (220 , $ floorY , 1008 ), $ landEvent ->position );
112112 }
113113
114114 public function testThrow2 (): void
@@ -195,7 +195,83 @@ public function testThrow3(): void
195195 $ this ->assertGreaterThan ($ bounceEvent ->position ->z , $ landEvent ->position ->z );
196196 $ this ->assertSame ($ y , $ bounceEvent ->position ->y );
197197 $ this ->assertSame ($ y , $ landEvent ->position ->y );
198- $ this ->assertPositionSame (new Point (470 , $ y , 470 ), $ landEvent ->position );
198+ $ this ->assertPositionSame (new Point (464 , $ y , 464 ), $ landEvent ->position );
199+ }
200+
201+ public function testThrow4 (): void
202+ {
203+ $ landEvent = null ;
204+ $ bounceEvents = null ;
205+ $ game = $ this ->createTestGame ();
206+ $ game ->getWorld ()->addWall ((new Wall (new Point (0 , 0 , 500 ), true , 100 ))->setNormal (45 , 45 ));
207+ $ game ->onEvents (function (array $ events ) use (&$ landEvent , &$ bounceEvent ): void {
208+ foreach ($ events as $ event ) {
209+ if (!($ event instanceof SoundEvent)) {
210+ continue ;
211+ }
212+ if ($ event ->type === SoundType::GRENADE_LAND ) {
213+ $ this ->assertTrue (is_null ($ landEvent ), 'Only one landEvent please ' );
214+ $ landEvent = $ event ;
215+ }
216+ if (!$ bounceEvent && $ event ->type === SoundType::GRENADE_BOUNCE ) {
217+ $ bounceEvent = $ event ;
218+ }
219+ }
220+ });
221+ $ this ->playPlayer ($ game , [
222+ fn (Player $ p ) => $ p ->getSight ()->look (10 , 45 ),
223+ fn (Player $ p ) => $ this ->assertTrue ($ p ->buyItem (BuyMenuItem::GRENADE_DECOY )),
224+ fn (Player $ p ) => $ this ->assertTrue ($ p ->equip (InventorySlot::SLOT_GRENADE_DECOY )),
225+ $ this ->waitNTicks (Decoy::equipReadyTimeMs),
226+ fn (Player $ p ) => $ this ->assertNotNull ($ p ->attack ()),
227+ $ this ->waitNTicks (1700 ),
228+ $ this ->endGame (),
229+ ]);
230+
231+ $ y = Decoy::boundingRadius;
232+ $ this ->assertFalse ($ game ->getPlayer (1 )->getInventory ()->has (InventorySlot::SLOT_GRENADE_DECOY ->value ));
233+ $ this ->assertInstanceOf (SoundEvent::class, $ bounceEvent );
234+ $ this ->assertInstanceOf (SoundEvent::class, $ landEvent );
235+ $ this ->assertPositionSame (new Point (86 , 430 , 490 ), $ bounceEvent ->position );
236+ $ this ->assertPositionSame (new Point (115 , 10 , 443 ), $ landEvent ->position );
237+ }
238+
239+ public function testThrow5 (): void
240+ {
241+ $ landEvent = null ;
242+ $ bounceEvents = null ;
243+ $ game = $ this ->createTestGame ();
244+ $ game ->getWorld ()->addWall ((new Wall (new Point (0 , 0 , 500 ), true , 76 ))->setNormal (135 , 45 ));
245+ $ game ->onEvents (function (array $ events ) use (&$ landEvent , &$ bounceEvent ): void {
246+ foreach ($ events as $ event ) {
247+ if (!($ event instanceof SoundEvent)) {
248+ continue ;
249+ }
250+ if ($ event ->type === SoundType::GRENADE_LAND ) {
251+ $ this ->assertTrue (is_null ($ landEvent ), 'Only one landEvent please ' );
252+ $ landEvent = $ event ;
253+ }
254+ if (!$ bounceEvent && $ event ->type === SoundType::GRENADE_BOUNCE ) {
255+ $ bounceEvent = $ event ;
256+ }
257+ }
258+ });
259+ $ this ->playPlayer ($ game , [
260+ fn (Player $ p ) => $ p ->getSight ()->look (10 , 45 ),
261+ fn (Player $ p ) => $ this ->assertTrue ($ p ->buyItem (BuyMenuItem::GRENADE_DECOY )),
262+ fn (Player $ p ) => $ this ->assertTrue ($ p ->equip (InventorySlot::SLOT_GRENADE_DECOY )),
263+ $ this ->waitNTicks (Decoy::equipReadyTimeMs),
264+ fn (Player $ p ) => $ this ->assertNotNull ($ p ->attack ()),
265+ $ this ->waitNTicks (1700 ),
266+ $ this ->endGame (),
267+ ]);
268+
269+ $ y = Decoy::boundingRadius;
270+ $ this ->assertFalse ($ game ->getPlayer (1 )->getInventory ()->has (InventorySlot::SLOT_GRENADE_DECOY ->value ));
271+ $ this ->assertInstanceOf (SoundEvent::class, $ bounceEvent );
272+ $ this ->assertInstanceOf (SoundEvent::class, $ landEvent );
273+ $ this ->assertPositionSame (new Point (86 , 430 , 490 ), $ bounceEvent ->position );
274+ $ this ->assertPositionSame (new Point (632 , 10 , 616 ), $ landEvent ->position );
199275 }
200276
201277 public function testThrowFlashBang (): void
@@ -278,7 +354,7 @@ private function _testFullVerticalThrow(int $floorY): void
278354 ]);
279355
280356 $ this ->assertFalse ($ game ->getPlayer (1 )->getInventory ()->has (InventorySlot::SLOT_GRENADE_DECOY ->value ));
281- $ this ->assertCount (4 , $ bounceEvents );
357+ $ this ->assertCount (5 , $ bounceEvents );
282358 $ bounceEvent = array_pop ($ bounceEvents );
283359 $ this ->assertInstanceOf (SoundEvent::class, $ bounceEvent ); // @phpstan-ignore-line
284360 $ this ->assertInstanceOf (SoundEvent::class, $ landEvent );
@@ -324,7 +400,7 @@ public function testThrowAgainstWall(): void
324400 $ pp = $ game ->getPlayer (1 )->getPositionClone ();
325401 $ this ->assertGreaterThan ($ pp ->x , $ landEvent ->position ->x );
326402 $ this ->assertGreaterThan ($ pp ->z , $ landEvent ->position ->z );
327- $ this ->assertPositionSame (new Point (703 , Decoy::boundingRadius, 374 ), $ landEvent ->position );
403+ $ this ->assertPositionSame (new Point (708 , Decoy::boundingRadius, 376 ), $ landEvent ->position );
328404 }
329405
330406 public function testMultiThrow (): void
@@ -439,7 +515,7 @@ public function testExtremePosition(): void
439515 $ this ->assertSame (Decoy::boundingRadius, $ test ->land ->y );
440516 $ this ->assertSame (1 , $ test ->bounceCount );
441517 $ this ->assertSame (-1 + Decoy::boundingRadius, $ test ->bounceX );
442- $ this ->assertSame (114 , $ test ->airCount );
518+ $ this ->assertSame (125 , $ test ->airCount );
443519 $ this ->assertFalse ($ test ->goingUp );
444520 }
445521
0 commit comments