mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Bucket: Added sounds for bucket fill/empty
This commit is contained in:
parent
33352638a9
commit
5f48433c95
@ -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;
|
||||
}
|
||||
|
@ -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){
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user