37 private ?
Record $record =
null;
44 if($player instanceof
Player){
45 if($this->record !==
null){
47 }elseif($item instanceof
Record){
48 $player->sendJukeboxPopup(KnownTranslationFactory::record_nowPlaying($item->getRecordType()->getTranslatableName()));
49 $this->insertRecord($item->
pop());
53 $this->position->getWorld()->setBlock($this->position, $this);
58 public function getRecord() : ?Record{
62 public function ejectRecord() : void{
63 if($this->record !== null){
64 $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $this->record);
70 public function insertRecord(Record $record) : void{
71 if($this->record === null){
72 $this->record = $record;
77 public function startSound() : void{
78 if($this->record !== null){
79 $this->position->getWorld()->addSound($this->position,
new RecordSound($this->record->getRecordType()));
83 public function stopSound() : void{
84 $this->position->getWorld()->addSound($this->position, new RecordStopSound());
87 public function onBreak(
Item $item, ?
Player $player =
null, array &$returnedItems = []) : bool{
89 return parent::onBreak($item, $player, $returnedItems);
93 $drops = parent::getDropsForCompatibleTool($item);
94 if($this->record !==
null){
95 $drops[] = $this->record;
101 parent::readStateFromWorld();
102 $jukebox = $this->position->getWorld()->getTile($this->position);
103 if($jukebox instanceof JukeboxTile){
104 $this->record = $jukebox->getRecord();
111 parent::writeStateToWorld();
112 $jukebox = $this->position->getWorld()->getTile($this->position);
113 if($jukebox instanceof JukeboxTile){
114 $jukebox->setRecord($this->record);