mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Automate creation of tiles when they are used to store block properties
This commit is contained in:
@ -59,8 +59,8 @@ class Skull extends Flowable{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function updateState() : void{
|
||||
parent::updateState();
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
if($tile instanceof TileSkull){
|
||||
$this->type = $tile->getType();
|
||||
@ -68,6 +68,15 @@ class Skull extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
$tile = Tile::createTile(Tile::SKULL, $this->getLevel(), TileSkull::createNBT($this));
|
||||
if($tile instanceof TileSkull){
|
||||
$tile->setRotation($this->rotation);
|
||||
$tile->setType($this->type);
|
||||
}
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 1;
|
||||
}
|
||||
@ -91,17 +100,7 @@ class Skull extends Flowable{
|
||||
if($player !== null and $face === Facing::UP){
|
||||
$this->rotation = ((int) floor(($player->yaw * 16 / 360) + 0.5)) & 0xf;
|
||||
}
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
//TODO: make this automatic on block set
|
||||
$tile = Tile::createTile(Tile::SKULL, $this->getLevel(), TileSkull::createNBT($this));
|
||||
if($tile instanceof TileSkull){
|
||||
$tile->setRotation($this->rotation);
|
||||
$tile->setType($this->type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function getItem() : Item{
|
||||
|
Reference in New Issue
Block a user