mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 19:24:12 +00:00
Automate creation of tiles when they are used to store block properties
This commit is contained in:
@ -74,16 +74,24 @@ class Bed extends Transparent{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function updateState() : void{
|
||||
parent::updateState();
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
//read extra state information from the tile - this is an ugly hack
|
||||
//TODO: extend this hack to setting block as well so we don't have to deal with tile hacks in the main code
|
||||
$tile = $this->level->getTile($this);
|
||||
if($tile instanceof TileBed){
|
||||
$this->color = $tile->getColor();
|
||||
}
|
||||
}
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
//extra block properties storage hack
|
||||
$tile = Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($this));
|
||||
if($tile instanceof TileBed){
|
||||
$tile->setColor($this->color);
|
||||
}
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.2;
|
||||
}
|
||||
@ -186,16 +194,6 @@ class Bed extends Transparent{
|
||||
$nextState->head = true;
|
||||
$this->getLevel()->setBlock($next, $nextState);
|
||||
|
||||
//TODO: make this happen automatically on block set
|
||||
$tile1 = Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($this));
|
||||
if($tile1 instanceof TileBed){
|
||||
$tile1->setColor($this->color);
|
||||
}
|
||||
$tile2 = Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($next));
|
||||
if($tile2 instanceof TileBed){
|
||||
$tile2->setColor($this->color);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user