Fixup pressure plate hierarchy

This commit is contained in:
Dylan K. Taylor 2019-02-21 13:06:08 +00:00
parent 28d01025b0
commit eabd8ce026
7 changed files with 141 additions and 47 deletions

View File

@ -0,0 +1,33 @@
<?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;
abstract class PressurePlate extends Transparent{
public function isSolid() : bool{
return false;
}
//TODO
}

View File

@ -0,0 +1,42 @@
<?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;
abstract class SimplePressurePlate extends PressurePlate{
/** @var bool */
protected $powered = false;
protected function writeStateToMeta() : int{
return $this->powered ? 1 : 0;
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->powered = $stateMeta !== 0;
}
public function getStateBitmask() : int{
return 0b1;
}
}

View File

@ -25,26 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\TieredTool;
class StonePressurePlate extends Transparent{
/** @var bool */
protected $powered = false;
protected function writeStateToMeta() : int{
return $this->powered ? 1 : 0;
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->powered = $stateMeta !== 0;
}
public function getStateBitmask() : int{
return 0b1;
}
public function isSolid() : bool{
return false;
}
class StonePressurePlate extends SimplePressurePlate{
public function getHardness() : float{
return 0.5;

View File

@ -0,0 +1,44 @@
<?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\BlockDataValidator;
abstract class WeightedPressurePlate extends PressurePlate{
/** @var int */
protected $power = 0;
protected function writeStateToMeta() : int{
return $this->power;
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
}
public function getStateBitmask() : int{
return 0b1111;
}
}

View File

@ -23,5 +23,19 @@ declare(strict_types=1);
namespace pocketmine\block;
class WeightedPressurePlateHeavy extends WeightedPressurePlateLight{
use pocketmine\item\TieredTool;
class WeightedPressurePlateHeavy extends WeightedPressurePlate{
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_PICKAXE;
}
public function getToolHarvestLevel() : int{
return TieredTool::TIER_WOODEN;
}
}

View File

@ -23,29 +23,9 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\BlockDataValidator;
use pocketmine\item\TieredTool;
class WeightedPressurePlateLight extends Transparent{
/** @var int */
protected $power = 0;
protected function writeStateToMeta() : int{
return $this->power;
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
}
public function getStateBitmask() : int{
return 0b1111;
}
public function isSolid() : bool{
return false;
}
class WeightedPressurePlateLight extends WeightedPressurePlate{
public function getHardness() : float{
return 0.5;

View File

@ -23,17 +23,17 @@ declare(strict_types=1);
namespace pocketmine\block;
class WoodenPressurePlate extends StonePressurePlate{
class WoodenPressurePlate extends SimplePressurePlate{
public function getFuelTime() : int{
return 300;
}
public function getHardness() : float{
return 0.5;
}
public function getToolType() : int{
return BlockToolType::TYPE_AXE;
}
public function getToolHarvestLevel() : int{
return 0; //TODO: fix hierarchy problem
}
}