Create sign tile like it should be.

This commit is contained in:
thebigsmileXD 2016-06-08 13:18:11 +02:00 committed by Dylan K. Taylor
parent 5f8dc5829c
commit 900c4adb66
2 changed files with 35 additions and 39 deletions

View File

@ -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],

View File

@ -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);