From 900c4adb6680f8bd903dd80c655a727be340e6d3 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Wed, 8 Jun 2016 13:18:11 +0200 Subject: [PATCH] Create sign tile like it should be. --- src/pocketmine/block/SignPost.php | 49 ++++++++++++++++++++++--------- src/pocketmine/level/Level.php | 25 ---------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index 7a8f03719..2a0b3277b 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -25,6 +25,12 @@ use pocketmine\item\Item; use pocketmine\item\Tool; use pocketmine\level\Level; use pocketmine\Player; +use pocketmine\math\Vector3; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; +use pocketmine\tile\Sign; +use pocketmine\tile\Tile; class SignPost extends Transparent{ @@ -53,17 +59,38 @@ class SignPost extends Transparent{ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ if($face !== 0){ - if($face === 1){ - $this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0F; - $this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true); + $nbt = new CompoundTag("", [ + "id" => new StringTag("id", Tile::SIGN), + "x" => new IntTag("x", $block->x), + "y" => new IntTag("y", $block->y), + "z" => new IntTag("z", $block->z), + "Text1" => new StringTag("Text1", ""), + "Text2" => new StringTag("Text2", ""), + "Text3" => new StringTag("Text3", ""), + "Text4" => new StringTag("Text4", "") + ]); - return true; + if($player !== null){ + $nbt->Creator = new StringTag("Creator", $player->getRawUniqueId()); + } + + if($item->hasCustomBlockData()){ + foreach($item->getCustomBlockData() as $key => $v){ + $nbt->{$key} = $v; + } + } + + if($face === 1){ + $this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0f; + $this->getLevel()->setBlock($block, $this, true); }else{ $this->meta = $face; - $this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true); - - return true; + $this->getLevel()->setBlock($block, new WallSign($this->meta), true); } + + Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt); + + return true; } return false; @@ -71,7 +98,7 @@ class SignPost extends Transparent{ public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->getId() === self::AIR){ + if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ $this->getLevel()->useBreakOn($this); return Level::BLOCK_UPDATE_NORMAL; @@ -81,12 +108,6 @@ class SignPost extends Transparent{ return false; } - public function onBreak(Item $item){ - $this->getLevel()->setBlock($this, new Air(), true, true); - - return true; - } - public function getDrops(Item $item){ return [ [Item::SIGN, 0, 1], diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 691fc3fa9..d5f257c2d 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1759,31 +1759,6 @@ class Level implements ChunkManager, Metadatable{ return false; } - if($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN){ - - $nbt = new CompoundTag("", [ - "id" => new StringTag("id", Tile::SIGN), - "x" => new IntTag("x", $block->x), - "y" => new IntTag("y", $block->y), - "z" => new IntTag("z", $block->z), - "Text1" => new StringTag("Text1", ""), - "Text2" => new StringTag("Text2", ""), - "Text3" => new StringTag("Text3", ""), - "Text4" => 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; - } - } - - Tile::createTile("Sign", $this->getChunk($block->x >> 4, $block->z >> 4), $nbt); - } $item->setCount($item->getCount() - 1); if($item->getCount() <= 0){ $item = Item::get(Item::AIR, 0, 0);