78 $tile = $this->position->getWorld()->getTile($this->position);
79 if($tile instanceof TileSign){
80 $this->frontText = $tile->getFrontText();
81 $this->backText = $tile->getBackText();
82 $this->waxed = $tile->isWaxed();
83 $this->editorEntityRuntimeId = $tile->getEditorEntityRuntimeId();
90 parent::writeStateToWorld();
91 $tile = $this->position->getWorld()->getTile($this->position);
92 assert($tile instanceof TileSign);
93 $tile->setFrontText($this->frontText);
94 $tile->setBackText($this->backText);
95 $tile->setWaxed($this->waxed);
96 $tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
156 if($text->isGlowing() !== $glowing && $this->doSignChange(
new SignText($text->getLines(), $text->getBaseColor(), $glowing), $player, $item, $frontFace)){
176 if($player === null){
183 $frontFace = $this->interactsFront($this->getHitboxCenter(), $player->getPosition(), $this->getFacingDegrees());
185 $dyeColor = $item instanceof Dye ? $item->getColor() : match($item->getTypeId()){
186 ItemTypeIds::BONE_MEAL => DyeColor::WHITE,
187 ItemTypeIds::LAPIS_LAZULI => DyeColor::BLUE,
188 ItemTypeIds::COCOA_BEANS => DyeColor::BROWN,
191 if($dyeColor !==
null){
192 $color = $dyeColor === DyeColor::BLACK ?
new Color(0, 0, 0) : $dyeColor->getRgbValue();
193 $text = $this->getFaceText($frontFace);
195 $color->toARGB() !== $text->getBaseColor()->toARGB() &&
196 $this->doSignChange(
new SignText($text->getLines(), $color, $text->isGlowing()), $player, $item, $frontFace)
198 $this->position->getWorld()->addSound($this->position,
new DyeUseSound());
201 }elseif(match($item->getTypeId()){
202 ItemTypeIds::INK_SAC => $this->changeSignGlowingState(false, $player, $item, $frontFace),
203 ItemTypeIds::GLOW_INK_SAC => $this->changeSignGlowingState(true, $player, $item, $frontFace),
204 ItemTypeIds::HONEYCOMB => $this->wax($player, $item),
215 private function interactsFront(Vector3 $hitboxCenter, Vector3 $playerPosition,
float $signFacingDegrees) : bool{
277 foreach($text->
getLines() as $line){
278 $size += strlen($line);
281 throw new \UnexpectedValueException($author->
getName() .
" tried to write $size bytes of text onto a sign (bigger than max 1000)");
283 $oldText = $this->getFaceText($frontFace);
284 $ev =
new SignChangeEvent($this, $author,
new SignText(array_map(
function(
string $line) :
string{
285 return TextFormat::clean($line,
false);
286 }, $text->
getLines()), $oldText->getBaseColor(), $oldText->isGlowing()), $frontFace);
287 if($this->waxed || $this->editorEntityRuntimeId !== $author->getId()){
291 if(!$ev->isCancelled()){
292 $this->setFaceText($frontFace, $ev->getNewText());
293 $this->setEditorEntityRuntimeId(
null);
294 $this->position->getWorld()->setBlock($this->position, $this);