Break Block's dependence on ItemFactory, and item legacy IDs

let's GOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
This commit is contained in:
Dylan K. Taylor
2022-07-02 17:29:28 +01:00
parent 9740891a2f
commit 323c563684
9 changed files with 113 additions and 73 deletions

View File

@ -41,9 +41,16 @@ abstract class BaseSign extends Transparent{
protected SignText $text;
protected ?int $editorEntityRuntimeId = null;
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
/** @var \Closure() : Item */
private \Closure $asItemCallback;
/**
* @param \Closure() : Item $asItemCallback
*/
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, \Closure $asItemCallback){
parent::__construct($idInfo, $name, $breakInfo);
$this->text = new SignText();
$this->asItemCallback = $asItemCallback;
}
public function readStateFromWorld() : void{
@ -139,4 +146,8 @@ abstract class BaseSign extends Transparent{
return false;
}
public function asItem() : Item{
return ($this->asItemCallback)();
}
}