mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 17:41:46 +00:00
Implement furnace sound (#4755)
closes #4363 The following classes have been added: - BlastFurnaceSound - SmokerSound - FurnaceSound
This commit is contained in:
parent
b9f1bcf0e4
commit
0bf5f97fe9
@ -26,9 +26,15 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\block\tile\Furnace as TileFurnace;
|
use pocketmine\block\tile\Furnace as TileFurnace;
|
||||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||||
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
||||||
|
use pocketmine\crafting\FurnaceType;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
|
use pocketmine\world\sound\BlastFurnaceSound;
|
||||||
|
use pocketmine\world\sound\FurnaceSound;
|
||||||
|
use pocketmine\world\sound\SmokerSound;
|
||||||
|
use function mt_rand;
|
||||||
|
|
||||||
class Furnace extends Opaque{
|
class Furnace extends Opaque{
|
||||||
use FacesOppositePlacingPlayerTrait;
|
use FacesOppositePlacingPlayerTrait;
|
||||||
@ -84,6 +90,14 @@ class Furnace extends Opaque{
|
|||||||
public function onScheduledUpdate() : void{
|
public function onScheduledUpdate() : void{
|
||||||
$furnace = $this->position->getWorld()->getTile($this->position);
|
$furnace = $this->position->getWorld()->getTile($this->position);
|
||||||
if($furnace instanceof TileFurnace && $furnace->onUpdate()){
|
if($furnace instanceof TileFurnace && $furnace->onUpdate()){
|
||||||
|
if(mt_rand(1, 60) === 1){ //in vanilla this is between 1 and 5 seconds; try to average about 3
|
||||||
|
$this->position->getWorld()->addSound($this->position, match($furnace->getFurnaceType()->id()){
|
||||||
|
FurnaceType::FURNACE()->id() => new FurnaceSound(),
|
||||||
|
FurnaceType::BLAST_FURNACE()->id() => new BlastFurnaceSound(),
|
||||||
|
FurnaceType::SMOKER()->id() => new SmokerSound(),
|
||||||
|
default => throw new AssumptionFailedError("Unreachable")
|
||||||
|
});
|
||||||
|
}
|
||||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, 1); //TODO: check this
|
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, 1); //TODO: check this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
src/world/sound/BlastFurnaceSound.php
Normal file
35
src/world/sound/BlastFurnaceSound.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\world\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||||
|
|
||||||
|
final class BlastFurnaceSound implements Sound{
|
||||||
|
|
||||||
|
public function encode(Vector3 $pos) : array{
|
||||||
|
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_BLASTFURNACE_FIRE_CRACKLE, $pos, false)];
|
||||||
|
}
|
||||||
|
}
|
35
src/world/sound/FurnaceSound.php
Normal file
35
src/world/sound/FurnaceSound.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\world\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||||
|
|
||||||
|
final class FurnaceSound implements Sound{
|
||||||
|
|
||||||
|
public function encode(Vector3 $pos) : array{
|
||||||
|
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_FURNACE_LIT, $pos, false)];
|
||||||
|
}
|
||||||
|
}
|
35
src/world/sound/SmokerSound.php
Normal file
35
src/world/sound/SmokerSound.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\world\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||||
|
|
||||||
|
final class SmokerSound implements Sound{
|
||||||
|
|
||||||
|
public function encode(Vector3 $pos) : array{
|
||||||
|
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_SMOKER_SMOKE, $pos, false)];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user