82 parent::writeStateToWorld();
83 $tile = $this->position->getWorld()->getTile($this->position);
84 assert($tile instanceof TileSign);
85 $tile->setText($this->text);
86 $tile->setWaxed($this->waxed);
87 $tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
133 private function doSignChange(SignText $newText,
Player $player, Item $item) : bool{
147 if($this->text->isGlowing() !== $glowing && $this->doSignChange(new SignText($this->text->getLines(), $this->text->getBaseColor(), $glowing), $player, $item)){
167 if($player === null){
174 $dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){
175 ItemTypeIds::BONE_MEAL => DyeColor::WHITE,
176 ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE,
177 ItemTypeIds::COCOA_BEANS => DyeColor::BROWN,
180 if($dyeColor !==
null){
181 $color = $dyeColor === DyeColor::BLACK ? new Color(0, 0, 0) : $dyeColor->getRgbValue();
183 $color->toARGB() !== $this->text->getBaseColor()->toARGB() &&
184 $this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item)
186 $this->position->getWorld()->addSound($this->position, new DyeUseSound());
189 }elseif(match($item->getTypeId()){
190 ItemTypeIds::INK_SAC => $this->changeSignGlowingState(false, $player, $item),
191 ItemTypeIds::GLOW_INK_SAC => $this->changeSignGlowingState(true, $player, $item),
192 ItemTypeIds::HONEYCOMB => $this->wax($player, $item),
198 $player->openSignEditor($this->position);
248 foreach($text->
getLines() as $line){
249 $size += strlen($line);
252 throw new \UnexpectedValueException($author->
getName() .
" tried to write $size bytes of text onto a sign (bigger than max 1000)");
254 $ev =
new SignChangeEvent($this, $author,
new SignText(array_map(
function(
string $line) :
string{
255 return TextFormat::clean($line,
false);
256 }, $text->
getLines()), $this->text->getBaseColor(), $this->text->isGlowing()));
257 if($this->waxed || $this->editorEntityRuntimeId !== $author->getId()){
261 if(!$ev->isCancelled()){
262 $this->setText($ev->getNewText());
263 $this->setEditorEntityRuntimeId(
null);
264 $this->position->getWorld()->setBlock($this->position, $this);