mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-10 07:49:42 +00:00
Automate creation and deletion of Tiles for appropriate blocks
closes #880
This commit is contained in:
parent
260c5dcf00
commit
01e7ebeb5c
@ -35,7 +35,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Bed as TileBed;
|
use pocketmine\tile\Bed as TileBed;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class Bed extends Transparent{
|
class Bed extends Transparent{
|
||||||
@ -84,13 +83,17 @@ class Bed extends Transparent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileBed::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function writeStateToWorld() : void{
|
public function writeStateToWorld() : void{
|
||||||
parent::writeStateToWorld();
|
parent::writeStateToWorld();
|
||||||
//extra block properties storage hack
|
//extra block properties storage hack
|
||||||
/** @var TileBed $tile */
|
$tile = $this->level->getTile($this);
|
||||||
$tile = TileFactory::create(TileBed::class, $this->getLevel(), $this->asVector3());
|
if($tile instanceof TileBed){
|
||||||
$tile->setColor($this->color);
|
$tile->setColor($this->color);
|
||||||
$this->level->addTile($tile);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
|
@ -41,6 +41,7 @@ use pocketmine\metadata\Metadatable;
|
|||||||
use pocketmine\metadata\MetadataValue;
|
use pocketmine\metadata\MetadataValue;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
|
use pocketmine\tile\TileFactory;
|
||||||
use function array_merge;
|
use function array_merge;
|
||||||
use function assert;
|
use function assert;
|
||||||
use function dechex;
|
use function dechex;
|
||||||
@ -172,8 +173,26 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
$this->collisionBoxes = null;
|
$this->collisionBoxes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class of Tile associated with this block.
|
||||||
|
*
|
||||||
|
* @return string|null class extending Tile, or null
|
||||||
|
*/
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function writeStateToWorld() : void{
|
public function writeStateToWorld() : void{
|
||||||
$this->level->getChunkAtPosition($this)->setBlock($this->x & 0xf, $this->y, $this->z & 0xf, $this->getId(), $this->getDamage());
|
$this->level->getChunkAtPosition($this)->setBlock($this->x & 0xf, $this->y, $this->z & 0xf, $this->getId(), $this->getDamage());
|
||||||
|
|
||||||
|
$tileType = $this->getTileClass();
|
||||||
|
$oldTile = $this->level->getTile($this);
|
||||||
|
if($oldTile !== null and ($tileType === null or !($oldTile instanceof $tileType))){
|
||||||
|
$oldTile->close();
|
||||||
|
}
|
||||||
|
if($tileType !== null){
|
||||||
|
$this->level->addTile(TileFactory::create($tileType, $this->level, $this->asVector3()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -315,6 +334,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function onBreak(Item $item, Player $player = null) : bool{
|
public function onBreak(Item $item, Player $player = null) : bool{
|
||||||
|
if(($t = $this->level->getTile($this)) !== null){
|
||||||
|
$t->onBlockDestroyed();
|
||||||
|
}
|
||||||
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR));
|
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Chest as TileChest;
|
use pocketmine\tile\Chest as TileChest;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
|
|
||||||
class Chest extends Transparent{
|
class Chest extends Transparent{
|
||||||
|
|
||||||
@ -55,6 +54,10 @@ class Chest extends Transparent{
|
|||||||
return 0b111;
|
return 0b111;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileChest::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
return 2.5;
|
return 2.5;
|
||||||
}
|
}
|
||||||
@ -73,34 +76,28 @@ class Chest extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
/** @var TileChest|null $pair */
|
|
||||||
$pair = null;
|
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||||
|
//TODO: this is fragile and might have unintended side effects on ender chests if modified carelessly
|
||||||
|
$tile = $this->level->getTile($this);
|
||||||
|
if($tile instanceof TileChest){
|
||||||
foreach([
|
foreach([
|
||||||
Facing::rotateY($player->getHorizontalFacing(), false),
|
Facing::rotateY($this->facing, true),
|
||||||
Facing::rotateY($player->getHorizontalFacing(), true)
|
Facing::rotateY($this->facing, false)
|
||||||
] as $side){
|
] as $side){
|
||||||
$c = $this->getSide($side);
|
$c = $this->getSide($side);
|
||||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
||||||
$tile = $this->getLevel()->getTile($c);
|
$pair = $this->level->getTile($c);
|
||||||
if($tile instanceof TileChest and !$tile->isPaired()){
|
if($pair instanceof TileChest and !$pair->isPaired()){
|
||||||
$pair = $tile;
|
$pair->pairWith($tile);
|
||||||
|
$tile->pairWith($pair);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
|
||||||
/** @var TileChest $tile */
|
|
||||||
$tile = TileFactory::createFromItem(TileChest::class, $this->getLevel(), $this->asVector3(), $item);
|
|
||||||
$this->level->addTile($tile);
|
|
||||||
|
|
||||||
if($pair instanceof TileChest){
|
|
||||||
$pair->pairWith($tile);
|
|
||||||
$tile->pairWith($pair);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,10 +28,8 @@ use pocketmine\item\Item;
|
|||||||
use pocketmine\item\TieredTool;
|
use pocketmine\item\TieredTool;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use pocketmine\math\Vector3;
|
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\EnchantTable as TileEnchantingTable;
|
use pocketmine\tile\EnchantTable as TileEnchantingTable;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
|
|
||||||
class EnchantingTable extends Transparent{
|
class EnchantingTable extends Transparent{
|
||||||
|
|
||||||
@ -41,13 +39,8 @@ class EnchantingTable extends Transparent{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
protected function getTileClass() : ?string{
|
||||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
return TileEnchantingTable::class;
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileEnchantingTable::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
|
@ -27,15 +27,17 @@ use pocketmine\item\Item;
|
|||||||
use pocketmine\item\ItemFactory;
|
use pocketmine\item\ItemFactory;
|
||||||
use pocketmine\item\TieredTool;
|
use pocketmine\item\TieredTool;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use pocketmine\math\Vector3;
|
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\EnderChest as TileEnderChest;
|
use pocketmine\tile\EnderChest as TileEnderChest;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
|
|
||||||
class EnderChest extends Chest{
|
class EnderChest extends Chest{
|
||||||
|
|
||||||
protected $id = self::ENDER_CHEST;
|
protected $id = self::ENDER_CHEST;
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileEnderChest::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
return 22.5;
|
return 22.5;
|
||||||
}
|
}
|
||||||
@ -60,19 +62,6 @@ class EnderChest extends Chest{
|
|||||||
return TieredTool::TIER_WOODEN;
|
return TieredTool::TIER_WOODEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
|
||||||
if($player !== null){ //same as normal chest - TODO: clean up inheritance here
|
|
||||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Block::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileEnderChest::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null) : bool{
|
public function onActivate(Item $item, Player $player = null) : bool{
|
||||||
if($player instanceof Player){
|
if($player instanceof Player){
|
||||||
$enderChest = $this->getLevel()->getTile($this);
|
$enderChest = $this->getLevel()->getTile($this);
|
||||||
|
@ -29,7 +29,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\FlowerPot as TileFlowerPot;
|
use pocketmine\tile\FlowerPot as TileFlowerPot;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
|
|
||||||
class FlowerPot extends Flowable{
|
class FlowerPot extends Flowable{
|
||||||
|
|
||||||
@ -55,6 +54,10 @@ class FlowerPot extends Flowable{
|
|||||||
return 0b1111; //vanilla uses various values, we only care about 1 and 0 for PE
|
return 0b1111; //vanilla uses various values, we only care about 1 and 0 for PE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileFlowerPot::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName() : string{
|
public function getName() : string{
|
||||||
return "Flower Pot";
|
return "Flower Pot";
|
||||||
}
|
}
|
||||||
@ -68,12 +71,7 @@ class FlowerPot extends Flowable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileFlowerPot::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -30,7 +30,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Furnace as TileFurnace;
|
use pocketmine\tile\Furnace as TileFurnace;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
|
|
||||||
class Furnace extends Solid{
|
class Furnace extends Solid{
|
||||||
|
|
||||||
@ -61,6 +60,10 @@ class Furnace extends Solid{
|
|||||||
return 0b111;
|
return 0b111;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileFurnace::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName() : string{
|
public function getName() : string{
|
||||||
return "Furnace";
|
return "Furnace";
|
||||||
}
|
}
|
||||||
@ -99,12 +102,8 @@ class Furnace extends Solid{
|
|||||||
if($player !== null){
|
if($player !== null){
|
||||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||||
}
|
}
|
||||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileFurnace::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null) : bool{
|
public function onActivate(Item $item, Player $player = null) : bool{
|
||||||
|
@ -29,7 +29,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\ItemFrame as TileItemFrame;
|
use pocketmine\tile\ItemFrame as TileItemFrame;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
use function lcg_value;
|
use function lcg_value;
|
||||||
|
|
||||||
class ItemFrame extends Flowable{
|
class ItemFrame extends Flowable{
|
||||||
@ -56,6 +55,10 @@ class ItemFrame extends Flowable{
|
|||||||
return 0b11;
|
return 0b11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileItemFrame::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName() : string{
|
public function getName() : string{
|
||||||
return "Item Frame";
|
return "Item Frame";
|
||||||
}
|
}
|
||||||
@ -86,13 +89,7 @@ class ItemFrame extends Flowable{
|
|||||||
|
|
||||||
$this->facing = $face;
|
$this->facing = $face;
|
||||||
|
|
||||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileItemFrame::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDropsForCompatibleTool(Item $item) : array{
|
public function getDropsForCompatibleTool(Item $item) : array{
|
||||||
|
@ -29,7 +29,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Sign as TileSign;
|
use pocketmine\tile\Sign as TileSign;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
use function floor;
|
use function floor;
|
||||||
|
|
||||||
class SignPost extends Transparent{
|
class SignPost extends Transparent{
|
||||||
@ -57,6 +56,10 @@ class SignPost extends Transparent{
|
|||||||
return 0b1111;
|
return 0b1111;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileSign::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -78,15 +81,10 @@ class SignPost extends Transparent{
|
|||||||
|
|
||||||
if($face === Facing::UP){
|
if($face === Facing::UP){
|
||||||
$this->rotation = $player !== null ? ((int) floor((($player->yaw + 180) * 16 / 360) + 0.5)) & 0x0f : 0;
|
$this->rotation = $player !== null ? ((int) floor((($player->yaw + 180) * 16 / 360) + 0.5)) & 0x0f : 0;
|
||||||
$ret = parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}else{
|
|
||||||
$ret = $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_SIGN, $face));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ret){
|
return $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_SIGN, $face));
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileSign::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -31,7 +31,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Skull as TileSkull;
|
use pocketmine\tile\Skull as TileSkull;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
use function floor;
|
use function floor;
|
||||||
|
|
||||||
class Skull extends Flowable{
|
class Skull extends Flowable{
|
||||||
@ -70,13 +69,18 @@ class Skull extends Flowable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileSkull::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function writeStateToWorld() : void{
|
public function writeStateToWorld() : void{
|
||||||
parent::writeStateToWorld();
|
parent::writeStateToWorld();
|
||||||
/** @var TileSkull $tile */
|
//extra block properties storage hack
|
||||||
$tile = TileFactory::create(TileSkull::class, $this->getLevel(), $this->asVector3());
|
$tile = $this->level->getTile($this);
|
||||||
|
if($tile instanceof TileSkull){
|
||||||
$tile->setRotation($this->rotation);
|
$tile->setRotation($this->rotation);
|
||||||
$tile->setType($this->type);
|
$tile->setType($this->type);
|
||||||
$this->level->addTile($tile);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
|
@ -31,7 +31,6 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\tile\Banner as TileBanner;
|
use pocketmine\tile\Banner as TileBanner;
|
||||||
use pocketmine\tile\TileFactory;
|
|
||||||
use function floor;
|
use function floor;
|
||||||
|
|
||||||
class StandingBanner extends Transparent{
|
class StandingBanner extends Transparent{
|
||||||
@ -59,6 +58,10 @@ class StandingBanner extends Transparent{
|
|||||||
return 0b1111;
|
return 0b1111;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getTileClass() : ?string{
|
||||||
|
return TileBanner::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -79,15 +82,10 @@ class StandingBanner extends Transparent{
|
|||||||
if($face !== Facing::DOWN){
|
if($face !== Facing::DOWN){
|
||||||
if($face === Facing::UP and $player !== null){
|
if($face === Facing::UP and $player !== null){
|
||||||
$this->rotation = ((int) floor((($player->yaw + 180) * 16 / 360) + 0.5)) & 0x0f;
|
$this->rotation = ((int) floor((($player->yaw + 180) * 16 / 360) + 0.5)) & 0x0f;
|
||||||
$ret = parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}else{
|
|
||||||
$ret = $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_BANNER, $face));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ret){
|
return $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_BANNER, $face));
|
||||||
$this->level->addTile(TileFactory::createFromItem(TileBanner::class, $this->getLevel(), $this->asVector3(), $item));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1869,6 +1869,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
if(!$hand->place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
if(!$hand->place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$tile = $this->getTile($hand);
|
||||||
|
if($tile !== null){
|
||||||
|
//TODO: seal this up inside block placement
|
||||||
|
$tile->copyDataFromItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
if($playSound){
|
if($playSound){
|
||||||
$this->broadcastLevelSoundEvent($hand, LevelSoundEventPacket::SOUND_PLACE, $hand->getRuntimeId());
|
$this->broadcastLevelSoundEvent($hand, LevelSoundEventPacket::SOUND_PLACE, $hand->getRuntimeId());
|
||||||
|
@ -36,7 +36,7 @@ use function assert;
|
|||||||
class Banner extends Spawnable implements Nameable{
|
class Banner extends Spawnable implements Nameable{
|
||||||
use NameableTrait {
|
use NameableTrait {
|
||||||
addAdditionalSpawnData as addNameSpawnData;
|
addAdditionalSpawnData as addNameSpawnData;
|
||||||
copyDataFromItem as copyNameFromItem;
|
copyDataFromItem as protected copyNameFromItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public const TAG_BASE = "Base";
|
public const TAG_BASE = "Base";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user