Skip to content
This repository was archived by the owner on Feb 2, 2018. It is now read-only.

Commit a81bccd

Browse files
committed
All sounds are back!
1 parent e377ce1 commit a81bccd

32 files changed

+2332
-2166
lines changed

src/pocketmine/block/Noteblock.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use pocketmine\math\Vector3;
1414
use pocketmine\level\sound\NoteblockSound;
1515
use pocketmine\tile\Music;
16+
use pocketmine\network\protocol\BlockEventPacket;
1617

1718
class Noteblock extends Solid{
1819

@@ -136,6 +137,15 @@ public function onActivate(Item $item, Player $player = null){
136137
}
137138
$tile->setNote($pitch);
138139
$this->level->addSound(new NoteblockSound($this, $instrument, $pitch));
140+
if($player instanceof Player){
141+
$pk = new BlockEventPacket();
142+
$pk->x = $this->x;
143+
$pk->y = $this->y;
144+
$pk->z = $this->z;
145+
$pk->case1 = $this->getInstrument();
146+
$pk->case2 = $pitch;
147+
$player->dataPacket($pk);
148+
}
139149
return true;
140150
}
141151
return false;

src/pocketmine/level/Level.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122

123123
use pocketmine\entity\ExperienceOrb;
124124
use pocketmine\network\protocol\ChangeDimensionPacket;
125+
use pocketmine\level\sound\BlockBreakSound;
125126

126127
#include <rules/Level.h>
127128

@@ -1887,6 +1888,7 @@ public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player =
18871888
}
18881889

18891890
$this->addParticle(new DestroyBlockParticle($target->add(0.5), $target), $players);
1891+
$this->addSound(new BlockBreakSound($target), $players);
18901892
}
18911893

18921894
$target->onBreak($item);

src/pocketmine/level/sound/AnvilBreakSound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class AnvilBreakSound extends GenericSound{
88
public function __construct(Vector3 $pos, $pitch = 0){
9-
parent::__construct($pos, 'random.anvil_break', $pitch);
9+
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, $pitch);
1010
}
1111
}

src/pocketmine/level/sound/AnvilFallSound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class AnvilFallSound extends GenericSound{
88
public function __construct(Vector3 $pos, $pitch = 0){
9-
parent::__construct($pos, 'random.anvil_land', $pitch);
9+
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_FALL, $pitch);
1010
}
1111
}

src/pocketmine/level/sound/AnvilUseSound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class AnvilUseSound extends GenericSound{
88
public function __construct(Vector3 $pos, $pitch = 0){
9-
parent::__construct($pos, 'random.anvil_use', $pitch);
9+
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_USE, $pitch);
1010
}
1111
}

src/pocketmine/level/sound/BatSound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class BatSound extends GenericSound{
88
public function __construct(Vector3 $pos, $pitch = 0){
9-
parent::__construct($pos, 'mob.bat.takeoff', $pitch);
9+
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_BAT_FLY, $pitch);
1010
}
1111
}

src/pocketmine/level/sound/BlazeShootSound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class BlazeShootSound extends GenericSound{
88
public function __construct(Vector3 $pos, $pitch = 0){
9-
parent::__construct($pos, 'mob.ghast.fireball', $pitch);
9+
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, $pitch);
1010
}
1111
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace pocketmine\level\sound;
4+
5+
use pocketmine\block\Block;
6+
7+
class BlockBreakSound extends GenericSound{
8+
protected $data;
9+
10+
public function __construct(Block $b){
11+
$this->data = $b->getId();
12+
parent::__construct($b, 'break', $this->data, $pitch = 0);
13+
}
14+
}

src/pocketmine/level/sound/BlockPlaceSound.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,24 @@
2323

2424
use pocketmine\block\Block;
2525
use pocketmine\network\protocol\LevelEventPacket;
26-
use pocketmine\network\protocol\LevelSoundEventPacket;
2726

2827
class BlockPlaceSound extends GenericSound{
2928

3029
protected $data;
3130

3231
public function __construct(Block $b){
33-
parent::__construct($b, '');
34-
#$this->data = $b->getId();
32+
parent::__construct($b, LevelEventPacket::EVENT_SOUND_BLOCK_PLACE);
33+
$this->data = $b->getId();
3534
}
3635

3736
public function encode(){
38-
/*$pk = new LevelEventPacket;
37+
$pk = new LevelEventPacket;
3938
$pk->evid = $this->id;
4039
$pk->x = $this->x;
4140
$pk->y = $this->y;
4241
$pk->z = $this->z;
4342
$pk->data = $this->data;
4443

45-
return $pk;*/
46-
47-
$pk = new LevelSoundEventPacket();
48-
$pk->sound = 2;
49-
$pk->x = $this->x;
50-
$pk->y = $this->y;
51-
$pk->z = $this->z;
52-
$pk->volume = 100;
53-
$pk->pitch = $this->pitch;
54-
$pk->unknownBool = true;
55-
$pk->unknownBool2 = true;
56-
5744
return $pk;
5845
}
5946
}

src/pocketmine/level/sound/ButtonClickSound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class ButtonClickSound extends GenericSound{
88
public function __construct(Vector3 $pos, $pitch = 1000){
9-
parent::__construct($pos, 'random.click', $pitch);
9+
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_BUTTON_CLICK, $pitch);
1010
}
1111
}

0 commit comments

Comments
 (0)