mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Tile: remove createNBT(), add create(), createFromData(), createFromItem()
This commit is contained in:
@ -86,9 +86,12 @@ class Bed extends Transparent{
|
||||
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);
|
||||
$tile = Tile::create(Tile::BED, $this->getLevel(), $this->asVector3());
|
||||
if($tile !== null){
|
||||
if($tile instanceof TileBed){
|
||||
$tile->setColor($this->color);
|
||||
}
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,10 @@ class Chest extends Transparent{
|
||||
}
|
||||
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
$tile = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this, $item));
|
||||
$tile = Tile::createFromItem(Tile::CHEST, $this->getLevel(), $this->asVector3(), $item);
|
||||
if($tile !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
|
||||
if($chest instanceof TileChest and $tile instanceof TileChest){
|
||||
$chest->pairWith($tile);
|
||||
|
@ -30,7 +30,6 @@ use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\EnchantTable as TileEnchantTable;
|
||||
use pocketmine\tile\Tile;
|
||||
|
||||
class EnchantingTable extends Transparent{
|
||||
@ -43,7 +42,9 @@ class EnchantingTable extends Transparent{
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel(), TileEnchantTable::createNBT($this, $item));
|
||||
if(($tile = Tile::createFromItem(Tile::ENCHANT_TABLE, $this->getLevel(), $this->asVector3(), $item)) !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,9 @@ class EnderChest extends Chest{
|
||||
}
|
||||
|
||||
if(Block::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
Tile::createTile(Tile::ENDER_CHEST, $this->getLevel(), TileEnderChest::createNBT($this, $item));
|
||||
if(($tile = Tile::createFromItem(Tile::ENDER_CHEST, $this->getLevel(), $this->asVector3(), $item)) !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,9 @@ class FlowerPot extends Flowable{
|
||||
}
|
||||
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
Tile::createTile(Tile::FLOWER_POT, $this->getLevel(), TileFlowerPot::createNBT($this, $item));
|
||||
if(($tile = Tile::createFromItem(Tile::FLOWER_POT, $this->getLevel(), $this->asVector3(), $item)) !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,9 @@ class Furnace extends Solid{
|
||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||
}
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this, $item));
|
||||
if(($tile = Tile::createFromItem(Tile::FURNACE, $this->getLevel(), $this->asVector3(), $item)) !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,9 @@ class ItemFrame extends Flowable{
|
||||
$this->facing = $face;
|
||||
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this, $item));
|
||||
if(($tile = Tile::createFromItem(Tile::ITEM_FRAME, $this->getLevel(), $this->asVector3(), $item)) !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Sign as TileSign;
|
||||
use pocketmine\tile\Tile;
|
||||
|
||||
class SignPost extends Transparent{
|
||||
@ -83,7 +82,9 @@ class SignPost extends Transparent{
|
||||
}
|
||||
|
||||
if($ret){
|
||||
Tile::createTile(Tile::SIGN, $this->getLevel(), TileSign::createNBT($this, $item));
|
||||
if(($tile = Tile::createFromItem(Tile::SIGN, $this->getLevel(), $this->asVector3(), $item)) !== null){
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +70,13 @@ class Skull extends Flowable{
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
parent::writeStateToWorld();
|
||||
$tile = Tile::createTile(Tile::SKULL, $this->getLevel(), TileSkull::createNBT($this));
|
||||
if($tile instanceof TileSkull){
|
||||
$tile->setRotation($this->rotation);
|
||||
$tile->setType($this->type);
|
||||
$tile = Tile::create(Tile::SKULL, $this->getLevel(), $this->asVector3());
|
||||
if($tile !== null){
|
||||
if($tile instanceof TileSkull){
|
||||
$tile->setRotation($this->rotation);
|
||||
$tile->setType($this->type);
|
||||
}
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Banner as ItemBanner;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -83,7 +84,17 @@ class StandingBanner extends Transparent{
|
||||
}
|
||||
|
||||
if($ret){
|
||||
Tile::createTile(Tile::BANNER, $this->getLevel(), TileBanner::createNBT($this, $item));
|
||||
$tile = Tile::createFromItem(Tile::BANNER, $this->getLevel(), $this->asVector3(), $item);
|
||||
if($tile !== null){
|
||||
if($tile instanceof TileBanner and $item instanceof ItemBanner){
|
||||
$tile->setBaseColor($item->getBaseColor());
|
||||
if(($patterns = $item->getPatterns()) !== null){
|
||||
$tile->setPatterns($patterns);
|
||||
}
|
||||
}
|
||||
|
||||
$this->level->addTile($tile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -105,8 +116,8 @@ class StandingBanner extends Transparent{
|
||||
$tile = $this->level->getTile($this);
|
||||
|
||||
$drop = ItemFactory::get(Item::BANNER, ($tile instanceof TileBanner ? $tile->getBaseColor() : 0));
|
||||
if($tile instanceof TileBanner and !($patterns = $tile->getPatterns())->empty()){
|
||||
$drop->setNamedTagEntry(clone $patterns);
|
||||
if($tile instanceof TileBanner and $drop instanceof ItemBanner and !($patterns = $tile->getPatterns())->empty()){
|
||||
$drop->setPatterns($patterns);
|
||||
}
|
||||
|
||||
return [$drop];
|
||||
|
Reference in New Issue
Block a user