mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-31 07:21:17 +00:00
70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?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\block;
|
|
|
|
use pocketmine\block\utils\MushroomBlockType;
|
|
use pocketmine\data\runtime\RuntimeDataReader;
|
|
use pocketmine\data\runtime\RuntimeDataWriter;
|
|
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
|
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
|
use pocketmine\item\Item;
|
|
use function mt_rand;
|
|
|
|
class RedMushroomBlock extends Opaque{
|
|
protected MushroomBlockType $mushroomBlockType;
|
|
|
|
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
|
$this->mushroomBlockType = MushroomBlockType::PORES();
|
|
parent::__construct($idInfo, $name, $breakInfo);
|
|
}
|
|
|
|
public function getRequiredStateDataBits() : int{ return 4; }
|
|
|
|
protected function decodeState(RuntimeDataReader $r) : void{
|
|
$this->mushroomBlockType = RuntimeEnumDeserializer::readMushroomBlockType($r);
|
|
}
|
|
|
|
protected function encodeState(RuntimeDataWriter $w) : void{
|
|
RuntimeEnumSerializer::writeMushroomBlockType($w, $this->mushroomBlockType);
|
|
}
|
|
|
|
public function getMushroomBlockType() : MushroomBlockType{ return $this->mushroomBlockType; }
|
|
|
|
/** @return $this */
|
|
public function setMushroomBlockType(MushroomBlockType $mushroomBlockType) : self{
|
|
$this->mushroomBlockType = $mushroomBlockType;
|
|
return $this;
|
|
}
|
|
|
|
public function getDropsForCompatibleTool(Item $item) : array{
|
|
return [
|
|
VanillaBlocks::RED_MUSHROOM()->asItem()->setCount(mt_rand(0, 2))
|
|
];
|
|
}
|
|
|
|
public function isAffectedBySilkTouch() : bool{
|
|
return true;
|
|
}
|
|
}
|