Merge remote-tracking branch 'origin/stable'

This commit is contained in:
Dylan K. Taylor
2021-05-05 11:14:01 +01:00
10 changed files with 113 additions and 15 deletions

View File

@ -53,6 +53,9 @@ class Sign extends Spawnable{
/** @var SignText */
protected $text;
/** @var int|null */
protected $editorEntityRuntimeId = null;
public function __construct(World $world, Vector3 $pos){
$this->text = new SignText();
parent::__construct($world, $pos);
@ -90,6 +93,22 @@ class Sign extends Spawnable{
$this->text = $text;
}
/**
* Returns the entity runtime ID of the player who placed this sign. Only the player whose entity ID matches this
* one may edit the sign text.
* This is needed because as of 1.16.220, there is still no reliable way to detect when the MCPE client closed the
* sign edit GUI, so we have no way to know when the text is finalized. This limits editing of the text to only the
* player who placed it, and only while that player is online.
* We can say for sure that the sign is finalized if either of the following occurs:
* - The player quits (after rejoin, the player's entity runtimeID will be different).
* - The chunk is unloaded (on next load, the entity runtimeID will be null, because it's not saved).
*/
public function getEditorEntityRuntimeId() : ?int{ return $this->editorEntityRuntimeId; }
public function setEditorEntityRuntimeId(?int $editorEntityRuntimeId) : void{
$this->editorEntityRuntimeId = $editorEntityRuntimeId;
}
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
$nbt->setString(self::TAG_TEXT_BLOB, implode("\n", $this->text->getLines()));
}