77 $tile = $this->position->getWorld()->getTile($this->position);
78 if($tile instanceof TileSign){
79 $this->text = $tile->getText();
80 $this->backText = $tile->getBackText();
81 $this->waxed = $tile->isWaxed();
82 $this->editorEntityRuntimeId = $tile->getEditorEntityRuntimeId();
89 parent::writeStateToWorld();
90 $tile = $this->position->getWorld()->getTile($this->position);
91 assert($tile instanceof TileSign);
92 $tile->setText($this->text);
93 $tile->setBackText($this->backText);
94 $tile->setWaxed($this->waxed);
95 $tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
155 if($text->
isGlowing() !== $glowing && $this->doSignChange(
new SignText($text->
getLines(), $text->
getBaseColor(), $glowing), $player, $item, $frontFace)){
175 if($player === null){
182 $frontFace = $this->interactsFront($this->getHitboxCenter(), $player->getPosition(), $this->getFacingDegrees());
184 $dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){
185 ItemTypeIds::BONE_MEAL => DyeColor::WHITE,
186 ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE,
187 ItemTypeIds::COCOA_BEANS => DyeColor::BROWN,
190 if($dyeColor !==
null){
191 $color = $dyeColor === DyeColor::BLACK ?
new Color(0, 0, 0) : $dyeColor->getRgbValue();
192 $text = $this->getFaceText($frontFace);
195 $this->doSignChange(
new SignText($text->
getLines(), $color, $text->
isGlowing()), $player, $item, $frontFace)
197 $this->position->getWorld()->addSound($this->position,
new DyeUseSound());
200 }elseif(match($item->getTypeId()){
201 ItemTypeIds::INK_SAC => $this->changeSignGlowingState(false, $player, $item, $frontFace),
202 ItemTypeIds::GLOW_INK_SAC => $this->changeSignGlowingState(true, $player, $item, $frontFace),
203 ItemTypeIds::HONEYCOMB => $this->wax($player, $item),
214 private function interactsFront(Vector3 $hitboxCenter, Vector3 $playerPosition,
float $signFacingDegrees) : bool{
308 foreach($text->
getLines() as $line){
309 $size += strlen($line);
312 throw new \UnexpectedValueException($author->
getName() .
" tried to write $size bytes of text onto a sign (bigger than max 1000)");
314 $oldText = $this->getFaceText($frontFace);
315 $ev =
new SignChangeEvent($this, $author,
new SignText(array_map(
function(
string $line) :
string{
316 return TextFormat::clean($line,
false);
317 }, $text->
getLines()), $oldText->getBaseColor(), $oldText->isGlowing()), $frontFace);
318 if($this->waxed || $this->editorEntityRuntimeId !== $author->getId()){
322 if(!$ev->isCancelled()){
323 $this->setFaceText($frontFace, $ev->getNewText());
324 $this->setEditorEntityRuntimeId(
null);
325 $this->position->getWorld()->setBlock($this->position, $this);