Added FurnaceType->getCookSound()

This commit is contained in:
Dylan K. Taylor
2022-01-25 19:01:49 +00:00
parent 0bf5f97fe9
commit ea161af4e5
2 changed files with 11 additions and 15 deletions

View File

@ -26,14 +26,9 @@ namespace pocketmine\block;
use pocketmine\block\tile\Furnace as TileFurnace;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
use pocketmine\crafting\FurnaceType;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
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{
@ -91,12 +86,7 @@ class Furnace extends Opaque{
$furnace = $this->position->getWorld()->getTile($this->position);
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()->addSound($this->position, $furnace->getFurnaceType()->getCookSound());
}
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, 1); //TODO: check this
}