mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 17:41:46 +00:00
Make more use of PoweredByRedstoneTrait
This commit is contained in:
parent
48ef8771cd
commit
5be03c3196
@ -25,6 +25,7 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\block\utils\BlockDataSerializer;
|
use pocketmine\block\utils\BlockDataSerializer;
|
||||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||||
|
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
@ -35,6 +36,7 @@ use pocketmine\world\sound\DoorSound;
|
|||||||
|
|
||||||
class Door extends Transparent{
|
class Door extends Transparent{
|
||||||
use HorizontalFacingTrait;
|
use HorizontalFacingTrait;
|
||||||
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $top = false;
|
protected $top = false;
|
||||||
@ -43,8 +45,6 @@ class Door extends Transparent{
|
|||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $open = false;
|
protected $open = false;
|
||||||
/** @var bool */
|
|
||||||
protected $powered = false;
|
|
||||||
|
|
||||||
protected function writeStateToMeta() : int{
|
protected function writeStateToMeta() : int{
|
||||||
if($this->top){
|
if($this->top){
|
||||||
|
@ -26,6 +26,7 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\block\tile\Hopper as TileHopper;
|
use pocketmine\block\tile\Hopper as TileHopper;
|
||||||
use pocketmine\block\utils\BlockDataSerializer;
|
use pocketmine\block\utils\BlockDataSerializer;
|
||||||
use pocketmine\block\utils\InvalidBlockStateException;
|
use pocketmine\block\utils\InvalidBlockStateException;
|
||||||
|
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
@ -34,11 +35,10 @@ use pocketmine\player\Player;
|
|||||||
use pocketmine\world\BlockTransaction;
|
use pocketmine\world\BlockTransaction;
|
||||||
|
|
||||||
class Hopper extends Transparent{
|
class Hopper extends Transparent{
|
||||||
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $facing = Facing::DOWN;
|
private $facing = Facing::DOWN;
|
||||||
/** @var bool */
|
|
||||||
private $powered = false;
|
|
||||||
|
|
||||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||||
$facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
$facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
||||||
|
@ -27,6 +27,7 @@ use pocketmine\block\tile\Comparator;
|
|||||||
use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
|
use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
|
||||||
use pocketmine\block\utils\BlockDataSerializer;
|
use pocketmine\block\utils\BlockDataSerializer;
|
||||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||||
|
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
@ -38,14 +39,13 @@ use function assert;
|
|||||||
class RedstoneComparator extends Flowable{
|
class RedstoneComparator extends Flowable{
|
||||||
use HorizontalFacingTrait;
|
use HorizontalFacingTrait;
|
||||||
use AnalogRedstoneSignalEmitterTrait;
|
use AnalogRedstoneSignalEmitterTrait;
|
||||||
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
/** @var BlockIdentifierFlattened */
|
/** @var BlockIdentifierFlattened */
|
||||||
protected $idInfo;
|
protected $idInfo;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $isSubtractMode = false;
|
protected $isSubtractMode = false;
|
||||||
/** @var bool */
|
|
||||||
protected $powered = false;
|
|
||||||
|
|
||||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::instant());
|
||||||
@ -96,16 +96,6 @@ class RedstoneComparator extends Flowable{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPowered() : bool{
|
|
||||||
return $this->powered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return $this */
|
|
||||||
public function setPowered(bool $powered) : self{
|
|
||||||
$this->powered = $powered;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AxisAlignedBB[]
|
* @return AxisAlignedBB[]
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,7 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\block\utils\BlockDataSerializer;
|
use pocketmine\block\utils\BlockDataSerializer;
|
||||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||||
|
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
@ -34,12 +35,11 @@ use pocketmine\world\BlockTransaction;
|
|||||||
|
|
||||||
class RedstoneRepeater extends Flowable{
|
class RedstoneRepeater extends Flowable{
|
||||||
use HorizontalFacingTrait;
|
use HorizontalFacingTrait;
|
||||||
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
/** @var BlockIdentifierFlattened */
|
/** @var BlockIdentifierFlattened */
|
||||||
protected $idInfo;
|
protected $idInfo;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
protected $powered = false;
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $delay = 1;
|
protected $delay = 1;
|
||||||
|
|
||||||
@ -72,18 +72,6 @@ class RedstoneRepeater extends Flowable{
|
|||||||
return [AxisAlignedBB::one()->trim(Facing::UP, 7 / 8)];
|
return [AxisAlignedBB::one()->trim(Facing::UP, 7 / 8)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPowered() : bool{
|
|
||||||
return $this->powered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setPowered(bool $powered = true) : self{
|
|
||||||
$this->powered = $powered;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
if(!$blockReplace->getSide(Facing::DOWN)->isTransparent()){
|
if(!$blockReplace->getSide(Facing::DOWN)->isTransparent()){
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user