mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Button: rename powered property to pressed
This commit is contained in:
parent
9872bb4cb8
commit
915d63a2e8
@ -37,16 +37,16 @@ abstract class Button extends Flowable{
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
protected $facing = Facing::DOWN;
|
protected $facing = Facing::DOWN;
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $powered = false;
|
protected $pressed = false;
|
||||||
|
|
||||||
protected function writeStateToMeta() : int{
|
protected function writeStateToMeta() : int{
|
||||||
return BlockDataSerializer::writeFacing($this->facing) | ($this->powered ? BlockLegacyMetadata::BUTTON_FLAG_POWERED : 0);
|
return BlockDataSerializer::writeFacing($this->facing) | ($this->pressed ? BlockLegacyMetadata::BUTTON_FLAG_POWERED : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||||
//TODO: in PC it's (6 - facing) for every meta except 0 (down)
|
//TODO: in PC it's (6 - facing) for every meta except 0 (down)
|
||||||
$this->facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
$this->facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
||||||
$this->powered = ($stateMeta & BlockLegacyMetadata::BUTTON_FLAG_POWERED) !== 0;
|
$this->pressed = ($stateMeta & BlockLegacyMetadata::BUTTON_FLAG_POWERED) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStateBitmask() : int{
|
public function getStateBitmask() : int{
|
||||||
@ -62,8 +62,8 @@ abstract class Button extends Flowable{
|
|||||||
abstract protected function getActivationTime() : int;
|
abstract protected function getActivationTime() : int;
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
if(!$this->powered){
|
if(!$this->pressed){
|
||||||
$this->powered = true;
|
$this->pressed = true;
|
||||||
$this->pos->getWorld()->setBlock($this->pos, $this);
|
$this->pos->getWorld()->setBlock($this->pos, $this);
|
||||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, $this->getActivationTime());
|
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, $this->getActivationTime());
|
||||||
$this->pos->getWorld()->addSound($this->pos->add(0.5, 0.5, 0.5), new RedstonePowerOnSound());
|
$this->pos->getWorld()->addSound($this->pos->add(0.5, 0.5, 0.5), new RedstonePowerOnSound());
|
||||||
@ -73,8 +73,8 @@ abstract class Button extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onScheduledUpdate() : void{
|
public function onScheduledUpdate() : void{
|
||||||
if($this->powered){
|
if($this->pressed){
|
||||||
$this->powered = false;
|
$this->pressed = false;
|
||||||
$this->pos->getWorld()->setBlock($this->pos, $this);
|
$this->pos->getWorld()->setBlock($this->pos, $this);
|
||||||
$this->pos->getWorld()->addSound($this->pos->add(0.5, 0.5, 0.5), new RedstonePowerOffSound());
|
$this->pos->getWorld()->addSound($this->pos->add(0.5, 0.5, 0.5), new RedstonePowerOffSound());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user