Bucket: Added sounds for bucket fill/empty

This commit is contained in:
Dylan K. Taylor 2018-01-03 14:27:41 +00:00
parent 33352638a9
commit 5f48433c95
4 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\Player;
use pocketmine\Server;
@ -56,6 +57,14 @@ class Lava extends Liquid{
return BlockFactory::get(Block::FLOWING_LAVA, $this->meta);
}
public function getBucketFillSound() : int{
return LevelSoundEventPacket::SOUND_BUCKET_FILL_LAVA;
}
public function getBucketEmptySound() : int{
return LevelSoundEventPacket::SOUND_BUCKET_EMPTY_LAVA;
}
public function tickRate() : int{
return 30;
}

View File

@ -80,6 +80,10 @@ abstract class Liquid extends Transparent{
abstract public function getFlowingForm() : Block;
abstract public function getBucketFillSound() : int;
abstract public function getBucketEmptySound() : int;
public function getFluidHeightPercent(){
$d = $this->meta;
if($d >= 8){

View File

@ -26,6 +26,7 @@ namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\Player;
class Water extends Liquid{
@ -52,6 +53,14 @@ class Water extends Liquid{
return BlockFactory::get(Block::FLOWING_WATER, $this->meta);
}
public function getBucketFillSound() : int{
return LevelSoundEventPacket::SOUND_BUCKET_FILL_WATER;
}
public function getBucketEmptySound() : int{
return LevelSoundEventPacket::SOUND_BUCKET_EMPTY_WATER;
}
public function tickRate() : int{
return 5;
}

View File

@ -63,6 +63,7 @@ class Bucket extends Item implements Consumable{
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem));
if(!$ev->isCancelled()){
$player->getLevel()->setBlock($blockClicked, BlockFactory::get(Block::AIR), true, true);
$player->getLevel()->broadcastLevelSoundEvent($blockClicked->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound());
if($player->isSurvival()){
if($stack->getCount() === 0){
$player->getInventory()->setItemInHand($ev->getItem());
@ -85,6 +86,8 @@ class Bucket extends Item implements Consumable{
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, $resultItem));
if(!$ev->isCancelled()){
$player->getLevel()->setBlock($blockReplace, $resultBlock->getFlowingForm(), true, true);
$player->getLevel()->broadcastLevelSoundEvent($blockClicked->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
if($player->isSurvival()){
$player->getInventory()->setItemInHand($ev->getItem());
}