81 parent::writeStateToWorld();
82 $tile = $this->position->getWorld()->getTile($this->position);
83 assert($tile instanceof TileSign);
84 $tile->setText($this->text);
85 $tile->setWaxed($this->waxed);
86 $tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
129 private function doSignChange(SignText $newText,
Player $player, Item $item) : bool{
143 if($this->text->isGlowing() !== $glowing && $this->doSignChange(new SignText($this->text->getLines(), $this->text->getBaseColor(), $glowing), $player, $item)){
163 if($player === null){
170 $dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){
171 ItemTypeIds::BONE_MEAL => DyeColor::WHITE,
172 ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE,
173 ItemTypeIds::COCOA_BEANS => DyeColor::BROWN,
176 if($dyeColor !==
null){
177 $color = $dyeColor === DyeColor::BLACK ? new Color(0, 0, 0) : $dyeColor->getRgbValue();
179 $color->toARGB() !== $this->text->getBaseColor()->toARGB() &&
180 $this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item)
182 $this->position->getWorld()->addSound($this->position, new DyeUseSound());
185 }elseif(match($item->getTypeId()){
186 ItemTypeIds::INK_SAC => $this->changeSignGlowingState(false, $player, $item),
187 ItemTypeIds::GLOW_INK_SAC => $this->changeSignGlowingState(true, $player, $item),
188 ItemTypeIds::HONEYCOMB => $this->wax($player, $item),
194 $player->openSignEditor($this->position);
244 foreach($text->
getLines() as $line){
245 $size += strlen($line);
248 throw new \UnexpectedValueException($author->
getName() .
" tried to write $size bytes of text onto a sign (bigger than max 1000)");
250 $ev =
new SignChangeEvent($this, $author,
new SignText(array_map(
function(
string $line) :
string{
251 return TextFormat::clean($line,
false);
252 }, $text->
getLines()), $this->text->getBaseColor(), $this->text->isGlowing()));
253 if($this->waxed || $this->editorEntityRuntimeId !== $author->getId()){
257 if(!$ev->isCancelled()){
258 $this->setText($ev->getNewText());
259 $this->setEditorEntityRuntimeId(
null);
260 $this->position->getWorld()->setBlock($this->position, $this);