mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Added on/off handling for buttons and levers
This commit is contained in:
@ -27,6 +27,7 @@ use pocketmine\item\Item;
|
||||
use pocketmine\math\Bearing;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Lever extends Flowable{
|
||||
@ -118,5 +119,15 @@ class Lever extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
$this->powered = !$this->powered;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->broadcastLevelSoundEvent(
|
||||
$this->add(0.5, 0.5, 0.5),
|
||||
$this->powered ? LevelSoundEventPacket::SOUND_POWER_ON : LevelSoundEventPacket::SOUND_POWER_OFF
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
Reference in New Issue
Block a user