Some cleanup to how tiles are created

This commit is contained in:
Dylan K. Taylor
2017-10-11 18:07:20 +01:00
parent be2d134994
commit b7a9e10d49
17 changed files with 155 additions and 205 deletions

View File

@ -27,10 +27,8 @@ use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\tile\Sign as TileSign;
use pocketmine\tile\Tile;
class SignPost extends Transparent{
@ -62,26 +60,6 @@ class SignPost extends Transparent{
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
if($face !== Vector3::SIDE_DOWN){
$nbt = new CompoundTag("", [
new StringTag("id", Tile::SIGN),
new IntTag("x", $blockReplace->x),
new IntTag("y", $blockReplace->y),
new IntTag("z", $blockReplace->z),
new StringTag("Text1", ""),
new StringTag("Text2", ""),
new StringTag("Text3", ""),
new StringTag("Text4", "")
]);
if($player !== null){
$nbt->Creator = new StringTag("Creator", $player->getRawUniqueId());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
if($face === Vector3::SIDE_UP){
$this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0f;
@ -91,7 +69,7 @@ class SignPost extends Transparent{
$this->getLevel()->setBlock($blockReplace, new WallSign($this->meta), true);
}
Tile::createTile(Tile::SIGN, $this->getLevel(), $nbt);
Tile::createTile(Tile::SIGN, $this->getLevel(), TileSign::createNBT($this, $face, $item, $player));
return true;
}