Skip to content

Commit b680a16

Browse files
authored
Added sound when picking sweet berries (#6287)
1 parent 0e5395c commit b680a16

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/block/SweetBerryBush.php

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use pocketmine\math\Facing;
3737
use pocketmine\math\Vector3;
3838
use pocketmine\player\Player;
39+
use pocketmine\world\sound\SweetBerriesPickSound;
3940
use function mt_rand;
4041

4142
class SweetBerryBush extends Flowable{
@@ -81,6 +82,7 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player
8182
}elseif(($dropAmount = $this->getBerryDropAmount()) > 0){
8283
$world->setBlock($this->position, $this->setAge(self::STAGE_BUSH_NO_BERRIES));
8384
$world->dropItem($this->position, $this->asItem()->setCount($dropAmount));
85+
$world->addSound($this->position, new SweetBerriesPickSound());
8486
}
8587

8688
return true;
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
declare(strict_types=1);
23+
24+
namespace pocketmine\world\sound;
25+
26+
use pocketmine\math\Vector3;
27+
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
28+
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
29+
30+
class SweetBerriesPickSound implements Sound{
31+
32+
public function encode(Vector3 $pos) : array{
33+
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_SWEET_BERRY_BUSH_PICK, $pos, false)];
34+
}
35+
}

0 commit comments

Comments
 (0)