mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Removed bad assumption that every Flowable descendent is an instant-breaking block
I'm wondering if there is even a point to Flowable at this point. Half of the blocks inheriting from it do not break instantly, or have some other modification to tool requirements.
This commit is contained in:
parent
01ad568256
commit
650e186481
@ -36,6 +36,10 @@ abstract class Crops extends Flowable{
|
||||
/** @var int */
|
||||
protected $age = 0;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ use pocketmine\Player;
|
||||
|
||||
class Dandelion extends Flowable{
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
|
@ -35,6 +35,10 @@ class DoublePlant extends Flowable{
|
||||
/** @var bool */
|
||||
protected $top = false;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return ($this->top ? self::BITFLAG_TOP : 0);
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ class EndRod extends Flowable{
|
||||
/** @var int */
|
||||
protected $facing = Facing::DOWN;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
if(Facing::axis($this->facing) === Facing::AXIS_Y){
|
||||
return $this->facing;
|
||||
|
@ -40,6 +40,10 @@ class Fire extends Flowable{
|
||||
/** @var int */
|
||||
protected $age = 0;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
}
|
||||
|
@ -27,10 +27,6 @@ use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
abstract class Flowable extends Transparent{
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function canBeFlowedInto() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ class Flower extends Flowable{
|
||||
public const TYPE_CORNFLOWER = 9;
|
||||
public const TYPE_LILY_OF_THE_VALLEY = 10;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === BlockLegacyIds::GRASS or $down->getId() === BlockLegacyIds::DIRT or $down->getId() === BlockLegacyIds::FARMLAND){
|
||||
|
@ -42,6 +42,10 @@ class FlowerPot extends Flowable{
|
||||
/** @var Block|null */
|
||||
protected $plant = null;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->occupied ? 1 : 0;
|
||||
}
|
||||
|
@ -37,6 +37,10 @@ class NetherWartPlant extends Flowable{
|
||||
/** @var int */
|
||||
protected $age = 0;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ use pocketmine\Player;
|
||||
|
||||
class RedMushroom extends Flowable{
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function ticksRandomly() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ class RedstoneComparator extends Flowable{
|
||||
/** @var int */
|
||||
protected $signalStrength = 0;
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name){
|
||||
parent::__construct($idInfo, $name);
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
|
@ -42,8 +42,8 @@ class RedstoneRepeater extends Flowable{
|
||||
/** @var int */
|
||||
protected $delay = 1;
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name){
|
||||
parent::__construct($idInfo, $name);
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
|
@ -30,6 +30,10 @@ class RedstoneWire extends Flowable{
|
||||
/** @var int */
|
||||
protected $power = 0;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ class Sapling extends Flowable{
|
||||
/** @var TreeType */
|
||||
private $treeType;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType){
|
||||
parent::__construct($idInfo, $name);
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
$this->treeType = $treeType;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,10 @@ use function mt_rand;
|
||||
|
||||
abstract class Stem extends Crops{
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
abstract protected function getPlant() : Block;
|
||||
|
||||
public function onRandomTick() : void{
|
||||
|
@ -36,6 +36,10 @@ class Sugarcane extends Flowable{
|
||||
/** @var int */
|
||||
protected $age = 0;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ class Torch extends Flowable{
|
||||
/** @var int */
|
||||
protected $facing = Facing::UP;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return 6 - $this->facing;
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ class Tripwire extends Flowable{
|
||||
/** @var bool */
|
||||
protected $disarmed = false;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return ($this->triggered ? 0x01 : 0) | ($this->suspended ? 0x02 : 0) | ($this->connected ? 0x04 : 0) | ($this->disarmed ? 0x08 : 0);
|
||||
}
|
||||
|
@ -39,6 +39,10 @@ class TripwireHook extends Flowable{
|
||||
/** @var bool */
|
||||
protected $powered = false;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return Bearing::fromFacing($this->facing) | ($this->connected ? 0x04 : 0) | ($this->powered ? 0x08 : 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user