mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 17:06:16 +00:00
Merge remote-tracking branch 'origin/stable'
This commit is contained in:
@ -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()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user