Hi, guys! I'm trying to clone one part of map to another place and stuck with tiles; On my map I have some WallSigns. I know how to clone them but I cant find how to define their orientation My tile cloning looks like: PHP: $tile = $level->getTile($old_pos); $level->addTile(cloneTile($new_pos, $tile)); ....... static function cloneTile(Position $pos, Sign $tile){ $txt = $tile->getText(); $nbt = new CompoundTag("", [ "id" => new StringTag("id", Tile::SIGN), "x" => new IntTag("x", $pos->getX()), "y" => new IntTag("y", $pos->getY()), "z" => new IntTag("z", $pos->getZ()), "Text1" => new StringTag("Text1", $txt[0]), "Text2" => new StringTag("Text2", $txt[1]), "Text3" => new StringTag("Text3", $txt[2]), "Text4" => new StringTag("Text4", $txt[3]) ]); } return Tile::createTile("Sign", Server::getInstance()->getDefaultLevel()->getChunk($pos->getX() >> 4, $pos->getZ() >> 4), $nbt); } But I guess, that not enough. After such cloning, all wallsigns turned to the one side and often just hangs near the wall in air. Does anyone know how to deal with WallSign orientaion? Thank you.
Save signs meta data PHP: \pocketmine\block\Sign::getDamage() To get block from tile it's PHP: \pocketmine\tile\Tile::getBlock(); You can save the return into NBT tag and get it back later. PHP: /** @var \pocketmine\tile\Sign $sign */$sign->getBlock()->setDamage($sign->namedtag->Meta);
In this particular case MC Wiky total usless. There are no answers HOW and WHERE to set that facing values Wow! What a nasty hack to use Damage for storing Orientation Now it works, TY! PHP: static function cloneTile(Position $pos, Sign $tile){ $meta = $tile->getBlock()->getDamage(); $txt = $tile->getText(); $nbt = new CompoundTag("", [ "id" => new StringTag("id", Tile::SIGN), "x" => new IntTag("x", $pos->getX()), "y" => new IntTag("y", $pos->getY()), "z" => new IntTag("z", $pos->getZ()), "Text1" => new StringTag("Text1", $txt[0]), "Text2" => new StringTag("Text2", $txt[1]), "Text3" => new StringTag("Text3", $txt[2]), "Text4" => new StringTag("Text4", $txt[3]) ]); $new_tile = Tile::createTile("Sign", Server::getInstance()->getDefaultLevel()->getChunk($pos->getX() >> 4, $pos->getZ() >> 4), $nbt); $new_tile->getBlock()->setDamage($meta); return $new_tile; }
This was my first attempt and it doesn't work. The new tile simple doesn't appear in the world. PHP: $new_tile = clone $tile;$new_tile->setComponents($new_pos->getX(), $new_pos->getY(), $new_pos->getZ());$level->addTile($new_tile); May be I just missed some additional initialisation
Tile isn't physical object but a meta data holder instead. Tile must be paired with block. PHP: $level->setBlock($new_pos, $new_tile->getBlock());
I doubt that this will work, because, as I see in the PM sources, that string is equal to $level->setBlock($new_pos, $level->getBlock($old_pos)); But, I'll try this way. As I understood tiles coordinates are stored in CompoundTags in tile's NBT. And after tile cloning these tags are still pointing to the old tile position. SetComponents method doesn't modify these tags