mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Revert back to separated floor/wall sign
the conditionally useless properties are problematic.
This commit is contained in:
parent
e6bf7278fc
commit
d3a3a41d2b
@ -39,46 +39,17 @@ use function assert;
|
||||
use function floor;
|
||||
use function strlen;
|
||||
|
||||
class Sign extends Transparent{
|
||||
/** @var BlockIdentifierFlattened */
|
||||
protected $idInfo;
|
||||
|
||||
abstract class BaseSign extends Transparent{
|
||||
//TODO: conditionally useless properties, find a way to fix
|
||||
|
||||
/** @var int */
|
||||
protected $rotation = 0;
|
||||
|
||||
/** @var int */
|
||||
protected $facing = Facing::UP;
|
||||
|
||||
/** @var SignText */
|
||||
protected $text;
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(1.0, BlockToolType::AXE));
|
||||
$this->text = new SignText();
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $this->facing === Facing::UP ? parent::getId() : $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
if($this->facing === Facing::UP){
|
||||
return $this->rotation;
|
||||
}
|
||||
return BlockDataSerializer::writeHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
if($id === $this->idInfo->getSecondId()){
|
||||
$this->facing = BlockDataSerializer::readHorizontalFacing($stateMeta);
|
||||
}else{
|
||||
$this->facing = Facing::UP;
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->pos->getWorld()->getTile($this->pos);
|
||||
@ -94,10 +65,6 @@ class Sign extends Transparent{
|
||||
$tile->setText($this->text);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function isSolid() : bool{
|
||||
return false;
|
||||
}
|
||||
@ -109,21 +76,10 @@ class Sign extends Transparent{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face !== Facing::DOWN){
|
||||
$this->facing = $face;
|
||||
if($face === Facing::UP){
|
||||
$this->rotation = $player !== null ? ((int) floor((($player->getLocation()->getYaw() + 180) * 16 / 360) + 0.5)) & 0x0f : 0;
|
||||
}
|
||||
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
abstract protected function getSupportingFace() : int;
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::opposite($this->facing))->getId() === BlockLegacyIds::AIR){
|
||||
if($this->getSide($this->getSupportingFace())->getId() === BlockLegacyIds::AIR){
|
||||
$this->pos->getWorld()->useBreakOn($this->pos);
|
||||
}
|
||||
}
|
@ -443,7 +443,8 @@ class BlockFactory{
|
||||
$this->register(new WoodenPressurePlate(BlockLegacyIdHelper::getWoodenPressurePlateIdentifier($treeType), $treeType->getDisplayName() . " Pressure Plate"));
|
||||
$this->register(new WoodenTrapdoor(BlockLegacyIdHelper::getWoodenTrapdoorIdentifier($treeType), $treeType->getDisplayName() . " Trapdoor"));
|
||||
|
||||
$this->register(new Sign(BlockLegacyIdHelper::getWoodenSignIdentifier($treeType), $treeType->getDisplayName() . " Sign"));
|
||||
$this->register(new FloorSign(BlockLegacyIdHelper::getWoodenFloorSignIdentifier($treeType), $treeType->getDisplayName() . " Sign"));
|
||||
$this->register(new WallSign(BlockLegacyIdHelper::getWoodenWallSignIdentifier($treeType), $treeType->getDisplayName() . " Wall Sign"));
|
||||
}
|
||||
|
||||
static $sandstoneTypes = [
|
||||
|
@ -34,20 +34,38 @@ use pocketmine\utils\AssumptionFailedError;
|
||||
|
||||
final class BlockLegacyIdHelper{
|
||||
|
||||
public static function getWoodenSignIdentifier(TreeType $treeType) : BIDFlattened{
|
||||
public static function getWoodenFloorSignIdentifier(TreeType $treeType) : BID{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BIDFlattened(Ids::SIGN_POST, Ids::WALL_SIGN, 0, ItemIds::SIGN, TileSign::class);
|
||||
return new BID(Ids::SIGN_POST, 0, ItemIds::SIGN, TileSign::class);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BIDFlattened(Ids::SPRUCE_STANDING_SIGN, Ids::SPRUCE_WALL_SIGN, 0, ItemIds::SPRUCE_SIGN, TileSign::class);
|
||||
return new BID(Ids::SPRUCE_STANDING_SIGN, 0, ItemIds::SPRUCE_SIGN, TileSign::class);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BIDFlattened(Ids::BIRCH_STANDING_SIGN, Ids::BIRCH_WALL_SIGN, 0, ItemIds::BIRCH_SIGN, TileSign::class);
|
||||
return new BID(Ids::BIRCH_STANDING_SIGN, 0, ItemIds::BIRCH_SIGN, TileSign::class);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BIDFlattened(Ids::JUNGLE_STANDING_SIGN, Ids::JUNGLE_WALL_SIGN, 0, ItemIds::JUNGLE_SIGN, TileSign::class);
|
||||
return new BID(Ids::JUNGLE_STANDING_SIGN, 0, ItemIds::JUNGLE_SIGN, TileSign::class);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BIDFlattened(Ids::ACACIA_STANDING_SIGN, Ids::ACACIA_WALL_SIGN, 0, ItemIds::ACACIA_SIGN, TileSign::class);
|
||||
return new BID(Ids::ACACIA_STANDING_SIGN,0, ItemIds::ACACIA_SIGN, TileSign::class);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BIDFlattened(Ids::DARKOAK_STANDING_SIGN, Ids::DARKOAK_WALL_SIGN, 0, ItemIds::DARKOAK_SIGN, TileSign::class);
|
||||
return new BID(Ids::DARKOAK_STANDING_SIGN, 0, ItemIds::DARKOAK_SIGN, TileSign::class);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
}
|
||||
|
||||
public static function getWoodenWallSignIdentifier(TreeType $treeType) : BID{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BID(Ids::WALL_SIGN, 0, ItemIds::SIGN, TileSign::class);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BID(Ids::SPRUCE_WALL_SIGN, 0, ItemIds::SPRUCE_SIGN, TileSign::class);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BID(Ids::BIRCH_WALL_SIGN, 0, ItemIds::BIRCH_SIGN, TileSign::class);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BID(Ids::JUNGLE_WALL_SIGN, 0, ItemIds::JUNGLE_SIGN, TileSign::class);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BID(Ids::ACACIA_WALL_SIGN, 0, ItemIds::ACACIA_SIGN, TileSign::class);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BID(Ids::DARKOAK_WALL_SIGN, 0, ItemIds::DARKOAK_SIGN, TileSign::class);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
}
|
||||
|
63
src/block/FloorSign.php
Normal file
63
src/block/FloorSign.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use function floor;
|
||||
|
||||
final class FloorSign extends BaseSign{
|
||||
/** @var int */
|
||||
protected $rotation = 0;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function getSupportingFace() : int{
|
||||
return Facing::DOWN;
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face !== Facing::UP){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($player !== null){
|
||||
$this->rotation = ((int) floor((($player->getLocation()->getYaw() + 180) * 16 / 360) + 0.5)) & 0x0f;
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
}
|
@ -40,10 +40,11 @@ use function assert;
|
||||
* @method static Planks ACACIA_PLANKS()
|
||||
* @method static WoodenPressurePlate ACACIA_PRESSURE_PLATE()
|
||||
* @method static Sapling ACACIA_SAPLING()
|
||||
* @method static Sign ACACIA_SIGN()
|
||||
* @method static FloorSign ACACIA_SIGN()
|
||||
* @method static WoodenSlab ACACIA_SLAB()
|
||||
* @method static WoodenStairs ACACIA_STAIRS()
|
||||
* @method static WoodenTrapdoor ACACIA_TRAPDOOR()
|
||||
* @method static WallSign ACACIA_WALL_SIGN()
|
||||
* @method static Wood ACACIA_WOOD()
|
||||
* @method static ActivatorRail ACTIVATOR_RAIL()
|
||||
* @method static Air AIR()
|
||||
@ -71,10 +72,11 @@ use function assert;
|
||||
* @method static Planks BIRCH_PLANKS()
|
||||
* @method static WoodenPressurePlate BIRCH_PRESSURE_PLATE()
|
||||
* @method static Sapling BIRCH_SAPLING()
|
||||
* @method static Sign BIRCH_SIGN()
|
||||
* @method static FloorSign BIRCH_SIGN()
|
||||
* @method static WoodenSlab BIRCH_SLAB()
|
||||
* @method static WoodenStairs BIRCH_STAIRS()
|
||||
* @method static WoodenTrapdoor BIRCH_TRAPDOOR()
|
||||
* @method static WallSign BIRCH_WALL_SIGN()
|
||||
* @method static Wood BIRCH_WOOD()
|
||||
* @method static Carpet BLACK_CARPET()
|
||||
* @method static Concrete BLACK_CONCRETE()
|
||||
@ -158,10 +160,11 @@ use function assert;
|
||||
* @method static Planks DARK_OAK_PLANKS()
|
||||
* @method static WoodenPressurePlate DARK_OAK_PRESSURE_PLATE()
|
||||
* @method static Sapling DARK_OAK_SAPLING()
|
||||
* @method static Sign DARK_OAK_SIGN()
|
||||
* @method static FloorSign DARK_OAK_SIGN()
|
||||
* @method static WoodenSlab DARK_OAK_SLAB()
|
||||
* @method static WoodenStairs DARK_OAK_STAIRS()
|
||||
* @method static WoodenTrapdoor DARK_OAK_TRAPDOOR()
|
||||
* @method static WallSign DARK_OAK_WALL_SIGN()
|
||||
* @method static Wood DARK_OAK_WOOD()
|
||||
* @method static Opaque DARK_PRISMARINE()
|
||||
* @method static Slab DARK_PRISMARINE_SLAB()
|
||||
@ -410,10 +413,11 @@ use function assert;
|
||||
* @method static Planks JUNGLE_PLANKS()
|
||||
* @method static WoodenPressurePlate JUNGLE_PRESSURE_PLATE()
|
||||
* @method static Sapling JUNGLE_SAPLING()
|
||||
* @method static Sign JUNGLE_SIGN()
|
||||
* @method static FloorSign JUNGLE_SIGN()
|
||||
* @method static WoodenSlab JUNGLE_SLAB()
|
||||
* @method static WoodenStairs JUNGLE_STAIRS()
|
||||
* @method static WoodenTrapdoor JUNGLE_TRAPDOOR()
|
||||
* @method static WallSign JUNGLE_WALL_SIGN()
|
||||
* @method static Wood JUNGLE_WOOD()
|
||||
* @method static ChemistryTable LAB_TABLE()
|
||||
* @method static Ladder LADDER()
|
||||
@ -496,10 +500,11 @@ use function assert;
|
||||
* @method static Planks OAK_PLANKS()
|
||||
* @method static WoodenPressurePlate OAK_PRESSURE_PLATE()
|
||||
* @method static Sapling OAK_SAPLING()
|
||||
* @method static Sign OAK_SIGN()
|
||||
* @method static FloorSign OAK_SIGN()
|
||||
* @method static WoodenSlab OAK_SLAB()
|
||||
* @method static WoodenStairs OAK_STAIRS()
|
||||
* @method static WoodenTrapdoor OAK_TRAPDOOR()
|
||||
* @method static WallSign OAK_WALL_SIGN()
|
||||
* @method static Wood OAK_WOOD()
|
||||
* @method static Opaque OBSIDIAN()
|
||||
* @method static Carpet ORANGE_CARPET()
|
||||
@ -624,10 +629,11 @@ use function assert;
|
||||
* @method static Planks SPRUCE_PLANKS()
|
||||
* @method static WoodenPressurePlate SPRUCE_PRESSURE_PLATE()
|
||||
* @method static Sapling SPRUCE_SAPLING()
|
||||
* @method static Sign SPRUCE_SIGN()
|
||||
* @method static FloorSign SPRUCE_SIGN()
|
||||
* @method static WoodenSlab SPRUCE_SLAB()
|
||||
* @method static WoodenStairs SPRUCE_STAIRS()
|
||||
* @method static WoodenTrapdoor SPRUCE_TRAPDOOR()
|
||||
* @method static WallSign SPRUCE_WALL_SIGN()
|
||||
* @method static Wood SPRUCE_WOOD()
|
||||
* @method static Opaque STONE()
|
||||
* @method static Slab STONE_BRICK_SLAB()
|
||||
@ -712,6 +718,7 @@ final class VanillaBlocks{
|
||||
self::register("acacia_slab", $factory->get(158, 4));
|
||||
self::register("acacia_stairs", $factory->get(163));
|
||||
self::register("acacia_trapdoor", $factory->get(400));
|
||||
self::register("acacia_wall_sign", $factory->get(446, 2));
|
||||
self::register("acacia_wood", $factory->get(467, 4));
|
||||
self::register("activator_rail", $factory->get(126));
|
||||
self::register("air", $factory->get(0));
|
||||
@ -743,6 +750,7 @@ final class VanillaBlocks{
|
||||
self::register("birch_slab", $factory->get(158, 2));
|
||||
self::register("birch_stairs", $factory->get(135));
|
||||
self::register("birch_trapdoor", $factory->get(401));
|
||||
self::register("birch_wall_sign", $factory->get(442, 2));
|
||||
self::register("birch_wood", $factory->get(467, 2));
|
||||
self::register("black_carpet", $factory->get(171, 15));
|
||||
self::register("black_concrete", $factory->get(236, 15));
|
||||
@ -830,6 +838,7 @@ final class VanillaBlocks{
|
||||
self::register("dark_oak_slab", $factory->get(158, 5));
|
||||
self::register("dark_oak_stairs", $factory->get(164));
|
||||
self::register("dark_oak_trapdoor", $factory->get(402));
|
||||
self::register("dark_oak_wall_sign", $factory->get(448, 2));
|
||||
self::register("dark_oak_wood", $factory->get(467, 5));
|
||||
self::register("dark_prismarine", $factory->get(168, 1));
|
||||
self::register("dark_prismarine_slab", $factory->get(182, 3));
|
||||
@ -1082,6 +1091,7 @@ final class VanillaBlocks{
|
||||
self::register("jungle_slab", $factory->get(158, 3));
|
||||
self::register("jungle_stairs", $factory->get(136));
|
||||
self::register("jungle_trapdoor", $factory->get(403));
|
||||
self::register("jungle_wall_sign", $factory->get(444, 2));
|
||||
self::register("jungle_wood", $factory->get(467, 3));
|
||||
self::register("lab_table", $factory->get(238, 12));
|
||||
self::register("ladder", $factory->get(65, 2));
|
||||
@ -1168,6 +1178,7 @@ final class VanillaBlocks{
|
||||
self::register("oak_slab", $factory->get(158));
|
||||
self::register("oak_stairs", $factory->get(53));
|
||||
self::register("oak_trapdoor", $factory->get(96));
|
||||
self::register("oak_wall_sign", $factory->get(68, 2));
|
||||
self::register("oak_wood", $factory->get(467));
|
||||
self::register("obsidian", $factory->get(49));
|
||||
self::register("orange_carpet", $factory->get(171, 1));
|
||||
@ -1296,6 +1307,7 @@ final class VanillaBlocks{
|
||||
self::register("spruce_slab", $factory->get(158, 1));
|
||||
self::register("spruce_stairs", $factory->get(134));
|
||||
self::register("spruce_trapdoor", $factory->get(404));
|
||||
self::register("spruce_wall_sign", $factory->get(437, 2));
|
||||
self::register("spruce_wood", $factory->get(467, 1));
|
||||
self::register("stone", $factory->get(1));
|
||||
self::register("stone_brick_slab", $factory->get(44, 5));
|
||||
|
61
src/block/WallSign.php
Normal file
61
src/block/WallSign.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class WallSign extends BaseSign{
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
protected function getSupportingFace() : int{
|
||||
return Facing::opposite($this->facing);
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(Facing::axis($face) === Axis::Y){
|
||||
return false;
|
||||
}
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ use function sprintf;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see \pocketmine\block\Sign
|
||||
* @see \pocketmine\block\BaseSign
|
||||
*/
|
||||
class Sign extends Spawnable{
|
||||
public const TAG_TEXT_BLOB = "Text";
|
||||
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\block;
|
||||
|
||||
use pocketmine\block\Sign;
|
||||
use pocketmine\block\BaseSign;
|
||||
use pocketmine\block\utils\SignText;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
@ -35,7 +35,7 @@ use pocketmine\player\Player;
|
||||
class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Sign */
|
||||
/** @var BaseSign */
|
||||
private $sign;
|
||||
|
||||
/** @var Player */
|
||||
@ -44,14 +44,14 @@ class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
/** @var SignText */
|
||||
private $text;
|
||||
|
||||
public function __construct(Sign $sign, Player $player, SignText $text){
|
||||
public function __construct(BaseSign $sign, Player $player, SignText $text){
|
||||
parent::__construct($sign);
|
||||
$this->sign = $sign;
|
||||
$this->player = $player;
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
public function getSign() : Sign{
|
||||
public function getSign() : BaseSign{
|
||||
return $this->sign;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ final class Bamboo extends Item{
|
||||
return 50;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::BAMBOO_SAPLING();
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class Banner extends Item{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::BANNER();
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Bed extends Item{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::BED();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class BeetrootSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::BEETROOTS();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Carrot extends Food{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::CARROTS();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class CocoaBeans extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::COCOA_POD();
|
||||
}
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ class Item implements \JsonSerializable{
|
||||
/**
|
||||
* Returns the block corresponding to this Item.
|
||||
*/
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::AIR();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ItemBlock extends Item{
|
||||
parent::__construct($identifier, $this->getBlock()->getName());
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return BlockFactory::getInstance()->get($this->blockId, $this->blockMeta);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
final class ItemBlockWallOrFloor{
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class ItemBlockWallOrFloor extends Item{
|
||||
|
||||
/** @var int */
|
||||
private $floorVariant;
|
||||
/** @var int */
|
||||
private $wallVariant;
|
||||
|
||||
public function __construct(ItemIdentifier $identifier, Block $floorVariant, Block $wallVariant){
|
||||
parent::__construct($identifier, $floorVariant->getName());
|
||||
$this->floorVariant = $floorVariant->getFullId();
|
||||
$this->wallVariant = $wallVariant->getFullId();
|
||||
}
|
||||
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
if($clickedFace !== null && Facing::axis($clickedFace) !== Axis::Y){
|
||||
return BlockFactory::getInstance()->fromFullBlock($this->wallVariant);
|
||||
}
|
||||
return BlockFactory::getInstance()->fromFullBlock($this->floorVariant);
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->getBlock()->getFuelTime();
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
@ -232,12 +233,12 @@ class ItemFactory{
|
||||
$this->register(new Redstone(new ItemIdentifier(ItemIds::REDSTONE, 0), "Redstone"));
|
||||
$this->register(new RottenFlesh(new ItemIdentifier(ItemIds::ROTTEN_FLESH, 0), "Rotten Flesh"));
|
||||
$this->register(new Shears(new ItemIdentifier(ItemIds::SHEARS, 0), "Shears"));
|
||||
$this->register(new Sign(BlockLegacyIds::STANDING_SIGN, 0, new ItemIdentifier(ItemIds::SIGN, 0)));
|
||||
$this->register(new Sign(BlockLegacyIds::SPRUCE_STANDING_SIGN, 0, new ItemIdentifier(ItemIds::SPRUCE_SIGN, 0)));
|
||||
$this->register(new Sign(BlockLegacyIds::BIRCH_STANDING_SIGN, 0, new ItemIdentifier(ItemIds::BIRCH_SIGN, 0)));
|
||||
$this->register(new Sign(BlockLegacyIds::JUNGLE_STANDING_SIGN, 0, new ItemIdentifier(ItemIds::JUNGLE_SIGN, 0)));
|
||||
$this->register(new Sign(BlockLegacyIds::ACACIA_STANDING_SIGN, 0, new ItemIdentifier(ItemIds::ACACIA_SIGN, 0)));
|
||||
$this->register(new Sign(BlockLegacyIds::DARKOAK_STANDING_SIGN, 0, new ItemIdentifier(ItemIds::DARKOAK_SIGN, 0)));
|
||||
$this->register(new Sign(new ItemIdentifier(ItemIds::SIGN, 0), VanillaBlocks::OAK_SIGN(), VanillaBlocks::OAK_WALL_SIGN()));
|
||||
$this->register(new Sign(new ItemIdentifier(ItemIds::SPRUCE_SIGN, 0), VanillaBlocks::SPRUCE_SIGN(), VanillaBlocks::SPRUCE_WALL_SIGN()));
|
||||
$this->register(new Sign(new ItemIdentifier(ItemIds::BIRCH_SIGN, 0), VanillaBlocks::BIRCH_SIGN(), VanillaBlocks::BIRCH_WALL_SIGN()));
|
||||
$this->register(new Sign(new ItemIdentifier(ItemIds::JUNGLE_SIGN, 0), VanillaBlocks::JUNGLE_SIGN(), VanillaBlocks::JUNGLE_WALL_SIGN()));
|
||||
$this->register(new Sign(new ItemIdentifier(ItemIds::ACACIA_SIGN, 0), VanillaBlocks::ACACIA_SIGN(), VanillaBlocks::ACACIA_WALL_SIGN()));
|
||||
$this->register(new Sign(new ItemIdentifier(ItemIds::DARKOAK_SIGN, 0), VanillaBlocks::DARK_OAK_SIGN(), VanillaBlocks::DARK_OAK_WALL_SIGN()));
|
||||
$this->register(new Snowball(new ItemIdentifier(ItemIds::SNOWBALL, 0), "Snowball"));
|
||||
$this->register(new SpiderEye(new ItemIdentifier(ItemIds::SPIDER_EYE, 0), "Spider Eye"));
|
||||
$this->register(new Steak(new ItemIdentifier(ItemIds::STEAK, 0), "Steak"));
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class MelonSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::MELON_STEM();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Potato extends Food{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::POTATOES();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class PumpkinSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::PUMPKIN_STEM();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class Redstone extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::REDSTONE_WIRE();
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
class Sign extends ItemBlock{
|
||||
class Sign extends ItemBlockWallOrFloor{
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 16;
|
||||
|
@ -37,7 +37,7 @@ class Skull extends Item{
|
||||
$this->skullType = $skullType;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::MOB_HEAD();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class StringItem extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::TRIPWIRE();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\VanillaBlocks;
|
||||
|
||||
class WheatSeeds extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
public function getBlock(?int $clickedFace = null) : Block{
|
||||
return VanillaBlocks::WHEAT();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\block\ItemFrame;
|
||||
use pocketmine\block\Sign;
|
||||
use pocketmine\block\BaseSign;
|
||||
use pocketmine\block\utils\SignText;
|
||||
use pocketmine\entity\animation\ConsumingItemAnimation;
|
||||
use pocketmine\entity\InvalidSkinException;
|
||||
@ -606,7 +606,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
$nbt = $packet->namedtag->getRoot();
|
||||
if(!($nbt instanceof CompoundTag)) throw new AssumptionFailedError("PHPStan should ensure this is a CompoundTag"); //for phpstorm's benefit
|
||||
|
||||
if($block instanceof Sign){
|
||||
if($block instanceof BaseSign){
|
||||
if(($textBlobTag = $nbt->getTag("Text")) instanceof StringTag){
|
||||
try{
|
||||
$text = SignText::fromBlob($textBlobTag->getValue());
|
||||
|
@ -1561,7 +1561,7 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
if($item->canBePlaced()){
|
||||
$hand = $item->getBlock();
|
||||
$hand = $item->getBlock($face);
|
||||
$hand->position($this, $blockReplace->getPos()->x, $blockReplace->getPos()->y, $blockReplace->getPos()->z);
|
||||
}else{
|
||||
return false;
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user