mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Added FurnaceType->getCookSound()
This commit is contained in:
parent
0bf5f97fe9
commit
ea161af4e5
@ -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
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\crafting;
|
||||
|
||||
use pocketmine\utils\EnumTrait;
|
||||
use pocketmine\world\sound\BlastFurnaceSound;
|
||||
use pocketmine\world\sound\FurnaceSound;
|
||||
use pocketmine\world\sound\SmokerSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
|
||||
/**
|
||||
* This doc-block is generated automatically, do not modify it manually.
|
||||
@ -42,15 +46,17 @@ final class FurnaceType{
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("furnace", 200),
|
||||
new self("blast_furnace", 100),
|
||||
new self("smoker", 100),
|
||||
new self("furnace", 200, new FurnaceSound()),
|
||||
new self("blast_furnace", 100, new BlastFurnaceSound()),
|
||||
new self("smoker", 100, new SmokerSound()),
|
||||
);
|
||||
}
|
||||
|
||||
private function __construct(string $enumName, private int $cookDurationTicks){
|
||||
private function __construct(string $enumName, private int $cookDurationTicks, private Sound $cookSound){
|
||||
$this->Enum___construct($enumName);
|
||||
}
|
||||
|
||||
public function getCookDurationTicks() : int{ return $this->cookDurationTicks; }
|
||||
|
||||
public function getCookSound() : Sound{ return $this->cookSound; }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user