diff --git a/src/pocketmine/block/ActivatorRail.php b/src/pocketmine/block/ActivatorRail.php index 88d4a9f7f..063cd6d25 100644 --- a/src/pocketmine/block/ActivatorRail.php +++ b/src/pocketmine/block/ActivatorRail.php @@ -25,11 +25,5 @@ namespace pocketmine\block; class ActivatorRail extends RedstoneRail{ - protected $id = self::ACTIVATOR_RAIL; - - public function getName() : string{ - return "Activator Rail"; - } - //TODO } diff --git a/src/pocketmine/block/Air.php b/src/pocketmine/block/Air.php index e7a11e0ea..33aeccb84 100644 --- a/src/pocketmine/block/Air.php +++ b/src/pocketmine/block/Air.php @@ -32,16 +32,6 @@ use pocketmine\math\AxisAlignedBB; */ class Air extends Transparent{ - protected $id = self::AIR; - - public function __construct(){ - - } - - public function getName() : string{ - return "Air"; - } - public function isBreakable(Item $item) : bool{ return false; } diff --git a/src/pocketmine/block/BaseRail.php b/src/pocketmine/block/BaseRail.php index d8cfdde8f..7dc0e48f7 100644 --- a/src/pocketmine/block/BaseRail.php +++ b/src/pocketmine/block/BaseRail.php @@ -80,10 +80,6 @@ abstract class BaseRail extends Flowable{ /** @var int[] */ protected $connections = []; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ if(empty($this->connections)){ return self::STRAIGHT_NORTH_SOUTH; diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index 6e2e08e8f..6123b35cf 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -41,10 +41,6 @@ class Bed extends Transparent{ private const BITFLAG_OCCUPIED = 0x04; private const BITFLAG_HEAD = 0x08; - protected $id = self::BED_BLOCK; - - protected $itemId = Item::BED; - /** @var int */ protected $facing = Facing::NORTH; /** @var bool */ @@ -54,7 +50,8 @@ class Bed extends Transparent{ /** @var DyeColor */ protected $color; - public function __construct(){ + public function __construct(BlockIdentifier $idInfo, string $name){ + parent::__construct($idInfo, $name); $this->color = DyeColor::RED(); } @@ -83,10 +80,6 @@ class Bed extends Transparent{ } } - protected function getTileClass() : ?string{ - return TileBed::class; - } - public function writeStateToWorld() : void{ parent::writeStateToWorld(); //extra block properties storage hack @@ -100,10 +93,6 @@ class Bed extends Transparent{ return 0.2; } - public function getName() : string{ - return "Bed Block"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ return AxisAlignedBB::one()->trim(Facing::UP, 7 / 16); } @@ -214,7 +203,7 @@ class Bed extends Transparent{ } public function getItem() : Item{ - return ItemFactory::get($this->getItemId(), $this->color->getMagicNumber()); + return ItemFactory::get($this->idInfo->getItemId(), $this->color->getMagicNumber()); } public function isAffectedBySilkTouch() : bool{ diff --git a/src/pocketmine/block/Bedrock.php b/src/pocketmine/block/Bedrock.php index c17173855..91fb7fe4c 100644 --- a/src/pocketmine/block/Bedrock.php +++ b/src/pocketmine/block/Bedrock.php @@ -27,16 +27,6 @@ use pocketmine\item\Item; class Bedrock extends Solid{ - protected $id = self::BEDROCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Bedrock"; - } - public function getHardness() : float{ return -1; } diff --git a/src/pocketmine/block/Beetroot.php b/src/pocketmine/block/Beetroot.php index b134fff2b..5158c8fc4 100644 --- a/src/pocketmine/block/Beetroot.php +++ b/src/pocketmine/block/Beetroot.php @@ -29,12 +29,6 @@ use function mt_rand; class Beetroot extends Crops{ - protected $id = self::BEETROOT_BLOCK; - - public function getName() : string{ - return "Beetroot Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ if($this->age >= 7){ return [ diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 18b4e3702..f0f40b94e 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -65,71 +65,50 @@ class Block extends Position implements BlockIds, Metadatable{ return BlockFactory::get($id, $meta, $pos); } - /** @var int */ - protected $id; - /** @var int */ - protected $variant = 0; + /** @var BlockIdentifier */ + protected $idInfo; + /** @var string|null */ protected $fallbackName; - /** @var int|null */ - protected $itemId; + /** @var AxisAlignedBB */ protected $boundingBox = null; - - /** @var AxisAlignedBB[]|null */ protected $collisionBoxes = null; /** - * @param int $id The block type's ID, 0-255 - * @param int $variant Meta value of the block type - * @param string|null $name English name of the block type (TODO: implement translations) - * @param int $itemId The item ID of the block type, used for block picking and dropping items. + * @param BlockIdentifier $idInfo + * @param string|null $name English name of the block type (TODO: implement translations) */ - public function __construct(int $id, int $variant = 0, string $name = null, int $itemId = null){ - $this->id = $id; - - if(($variant & $this->getStateBitmask()) !== 0){ - throw new \InvalidArgumentException("Variant 0x" . dechex($variant) . " collides with state bitmask 0x" . dechex($this->getStateBitmask())); + public function __construct(BlockIdentifier $idInfo, string $name){ + if(($idInfo->getVariant() & $this->getStateBitmask()) !== 0){ + throw new \InvalidArgumentException("Variant 0x" . dechex($idInfo->getVariant()) . " collides with state bitmask 0x" . dechex($this->getStateBitmask())); } - $this->variant = $variant; + $this->idInfo = $idInfo; $this->fallbackName = $name; - $this->itemId = $itemId; + } + + public function getIdInfo() : BlockIdentifier{ + return $this->idInfo; } /** * @return string */ public function getName() : string{ - return $this->fallbackName ?? "Unknown"; + return $this->fallbackName; } /** * @return int */ public function getId() : int{ - return $this->id; - } - - /** - * Returns the ID of the item form of the block. - * Used for drops for blocks (some blocks such as doors have a different item ID). - * - * @return int - */ - public function getItemId() : int{ - if($this->itemId !== null){ - return $this->itemId; - } - if($this->id > 255){ - return 255 - $this->id; - } - return $this->id; + return $this->idInfo->getBlockId(); } public function getItem() : Item{ - return ItemFactory::get($this->getItemId(), $this->getVariant()); + return ItemFactory::get($this->idInfo->getItemId(), $this->idInfo->getVariant()); } /** @@ -146,7 +125,7 @@ class Block extends Position implements BlockIds, Metadatable{ public function getDamage() : int{ $stateMeta = $this->writeStateToMeta(); assert(($stateMeta & ~$this->getStateBitmask()) === 0); - return $this->variant | $stateMeta; + return $this->idInfo->getVariant() | $stateMeta; } protected function writeStateToMeta() : int{ @@ -173,19 +152,10 @@ class Block extends Position implements BlockIds, Metadatable{ $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{ $this->level->getChunkAtPosition($this)->setBlock($this->x & 0xf, $this->y, $this->z & 0xf, $this->getId(), $this->getDamage()); - $tileType = $this->getTileClass(); + $tileType = $this->idInfo->getTileClass(); $oldTile = $this->level->getTile($this); if($oldTile !== null and ($tileType === null or !($oldTile instanceof $tileType))){ $oldTile->close(); @@ -205,14 +175,6 @@ class Block extends Position implements BlockIds, Metadatable{ return 0; } - /** - * Returns the block meta, stripped of non-variant flags. - * @return int - */ - public function getVariant() : int{ - return $this->variant; - } - /** * Returns whether the given block has an equivalent type to this one. * @@ -221,7 +183,7 @@ class Block extends Position implements BlockIds, Metadatable{ * @return bool */ public function isSameType(Block $other) : bool{ - return $this->getId() === $other->getId() and $this->getVariant() === $other->getVariant(); + return $this->idInfo->getBlockId() === $other->idInfo->getBlockId() and $this->idInfo->getVariant() === $other->idInfo->getVariant(); } /** diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 11643f7cc..f271e2ef0 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -23,12 +23,13 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\BlockIdentifier as BID; use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\InvalidBlockStateException; use pocketmine\block\utils\PillarRotationTrait; use pocketmine\block\utils\SlabType; use pocketmine\block\utils\TreeType; -use pocketmine\item\Item; +use pocketmine\item\ItemIds; use pocketmine\level\Position; use function array_fill; use function file_get_contents; @@ -76,256 +77,256 @@ class BlockFactory{ self::$stateMasks = new \SplFixedArray(8192); - self::register(new ActivatorRail()); - self::register(new Air()); - self::register(new Anvil(Block::ANVIL, Anvil::TYPE_NORMAL, "Anvil")); - self::register(new Anvil(Block::ANVIL, Anvil::TYPE_SLIGHTLY_DAMAGED, "Slightly Damaged Anvil")); - self::register(new Anvil(Block::ANVIL, Anvil::TYPE_VERY_DAMAGED, "Very Damaged Anvil")); - self::register(new Bed()); - self::register(new Bedrock()); - self::register(new Beetroot()); - self::register(new BoneBlock()); - self::register(new Bookshelf()); - self::register(new BrewingStand()); - self::register(new BrickStairs()); - self::register(new Bricks()); - self::register(new BrownMushroom()); - self::register(new BrownMushroomBlock()); - self::register(new Cactus()); - self::register(new Cake()); - self::register(new Carrot()); - self::register(new Chest()); - self::register(new Clay()); - self::register(new Coal()); - self::register(new CoalOre()); - self::register(new CoarseDirt(Block::DIRT, Dirt::COARSE, "Coarse Dirt")); - self::register(new Cobblestone()); - self::register(new CobblestoneStairs()); - self::register(new Cobweb()); - self::register(new CocoaBlock()); - self::register(new CraftingTable()); - self::register(new Dandelion()); - self::register(new DaylightSensor()); - self::register((new DaylightSensor())->setInverted()); //flattening hack - self::register(new DeadBush()); - self::register(new DetectorRail()); - self::register(new Diamond()); - self::register(new DiamondOre()); - self::register(new Dirt(Block::DIRT, Dirt::NORMAL, "Dirt")); - self::register(new DoublePlant(Block::DOUBLE_PLANT, 0, "Sunflower")); - self::register(new DoublePlant(Block::DOUBLE_PLANT, 1, "Lilac")); - self::register(new DoublePlant(Block::DOUBLE_PLANT, 4, "Rose Bush")); - self::register(new DoublePlant(Block::DOUBLE_PLANT, 5, "Peony")); - self::register(new DoubleTallGrass(Block::DOUBLE_PLANT, 2, "Double Tallgrass")); - self::register(new DoubleTallGrass(Block::DOUBLE_PLANT, 3, "Large Fern")); - self::register(new Emerald()); - self::register(new EmeraldOre()); - self::register(new EnchantingTable()); - self::register(new EndPortalFrame()); - self::register(new EndRod()); - self::register(new EndStone()); - self::register(new EndStoneBricks()); - self::register(new EnderChest()); - self::register(new Farmland()); - self::register(new FenceGate(Block::ACACIA_FENCE_GATE, 0, "Acacia Fence Gate")); - self::register(new FenceGate(Block::BIRCH_FENCE_GATE, 0, "Birch Fence Gate")); - self::register(new FenceGate(Block::DARK_OAK_FENCE_GATE, 0, "Dark Oak Fence Gate")); - self::register(new FenceGate(Block::JUNGLE_FENCE_GATE, 0, "Jungle Fence Gate")); - self::register(new FenceGate(Block::OAK_FENCE_GATE, 0, "Oak Fence Gate")); - self::register(new FenceGate(Block::SPRUCE_FENCE_GATE, 0, "Spruce Fence Gate")); - self::register(new Fire()); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_ALLIUM, "Allium")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_AZURE_BLUET, "Azure Bluet")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_BLUE_ORCHID, "Blue Orchid")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_ORANGE_TULIP, "Orange Tulip")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_OXEYE_DAISY, "Oxeye Daisy")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_PINK_TULIP, "Pink Tulip")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_POPPY, "Poppy")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_RED_TULIP, "Red Tulip")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_WHITE_TULIP, "White Tulip")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_CORNFLOWER, "Cornflower")); - self::register(new Flower(Block::RED_FLOWER, Flower::TYPE_LILY_OF_THE_VALLEY, "Lily of the Valley")); - self::register(new FlowerPot()); - self::register(new Furnace()); - self::register((new Furnace())->setLit()); //flattening hack - self::register(new Glass(Block::GLASS, 0, "Glass")); - self::register(new GlassPane(Block::GLASS_PANE, 0, "Glass Pane")); - self::register(new GlazedTerracotta(Block::BLACK_GLAZED_TERRACOTTA, 0, "Black Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::BLUE_GLAZED_TERRACOTTA, 0, "Blue Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::BROWN_GLAZED_TERRACOTTA, 0, "Brown Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::CYAN_GLAZED_TERRACOTTA, 0, "Cyan Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::GRAY_GLAZED_TERRACOTTA, 0, "Grey Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::GREEN_GLAZED_TERRACOTTA, 0, "Green Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::LIGHT_BLUE_GLAZED_TERRACOTTA, 0, "Light Blue Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::LIME_GLAZED_TERRACOTTA, 0, "Lime Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::MAGENTA_GLAZED_TERRACOTTA, 0, "Magenta Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::ORANGE_GLAZED_TERRACOTTA, 0, "Orange Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::PINK_GLAZED_TERRACOTTA, 0, "Pink Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::PURPLE_GLAZED_TERRACOTTA, 0, "Purple Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::RED_GLAZED_TERRACOTTA, 0, "Red Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::SILVER_GLAZED_TERRACOTTA, 0, "Light Grey Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::WHITE_GLAZED_TERRACOTTA, 0, "White Glazed Terracotta")); - self::register(new GlazedTerracotta(Block::YELLOW_GLAZED_TERRACOTTA, 0, "Yellow Glazed Terracotta")); - self::register(new GlowingObsidian()); - self::register(new Glowstone()); - self::register(new Gold()); - self::register(new GoldOre()); - self::register(new Grass()); - self::register(new GrassPath()); - self::register(new Gravel()); - self::register(new HardenedClay(Block::HARDENED_CLAY, 0, "Hardened Clay")); - self::register(new HardenedGlass(Block::HARD_GLASS, 0, "Hardened Glass")); - self::register(new HardenedGlassPane(Block::HARD_GLASS_PANE, 0, "Hardened Glass Pane")); - self::register(new HayBale()); - self::register(new Ice()); - self::register(new InfoUpdate(Block::INFO_UPDATE, 0, "update!")); - self::register(new InfoUpdate(Block::INFO_UPDATE2, 0, "ate!upd")); - self::register(new InvisibleBedrock()); - self::register(new Iron()); - self::register(new IronBars()); - self::register(new IronDoor()); - self::register(new IronOre()); - self::register(new IronTrapdoor()); - self::register(new ItemFrame()); - self::register(new Ladder()); - self::register(new Lapis()); - self::register(new LapisOre()); - self::register(new Lava()); - self::register((new Lava())->setStill()); //flattening hack - self::register(new Lever()); - self::register(new LitPumpkin()); - self::register(new Magma()); - self::register(new Melon()); - self::register(new MelonStem()); - self::register(new MonsterSpawner()); - self::register(new MossyCobblestone()); - self::register(new Mycelium()); - self::register(new NetherBrick(Block::NETHER_BRICK_BLOCK, 0, "Nether Bricks")); - self::register(new NetherBrick(Block::RED_NETHER_BRICK, 0, "Red Nether Bricks")); - self::register(new NetherBrickFence()); - self::register(new NetherBrickStairs()); - self::register(new NetherQuartzOre()); - self::register(new NetherReactor()); - self::register(new NetherWartBlock()); - self::register(new NetherWartPlant()); - self::register(new Netherrack()); - self::register(new NoteBlock()); - self::register(new Obsidian()); - self::register(new PackedIce()); - self::register(new Podzol()); - self::register(new Potato()); - self::register(new PoweredRail()); - self::register(new Prismarine(Block::PRISMARINE, Prismarine::BRICKS, "Prismarine Bricks")); - self::register(new Prismarine(Block::PRISMARINE, Prismarine::DARK, "Dark Prismarine")); - self::register(new Prismarine(Block::PRISMARINE, Prismarine::NORMAL, "Prismarine")); - self::register(new Pumpkin()); - self::register(new PumpkinStem()); - self::register(new Purpur(Block::PURPUR_BLOCK, 0, "Purpur Block")); - self::register(new class(Block::PURPUR_BLOCK, 2, "Purpur Pillar") extends Purpur{ + self::register(new ActivatorRail(new BID(Block::ACTIVATOR_RAIL, BaseRail::STRAIGHT_NORTH_SOUTH), "Activator Rail")); + self::register(new Air(new BID(Block::AIR), "Air")); + self::register(new Anvil(new BID(Block::ANVIL, Anvil::TYPE_NORMAL), "Anvil")); + self::register(new Anvil(new BID(Block::ANVIL, Anvil::TYPE_SLIGHTLY_DAMAGED), "Slightly Damaged Anvil")); + self::register(new Anvil(new BID(Block::ANVIL, Anvil::TYPE_VERY_DAMAGED), "Very Damaged Anvil")); + self::register(new Bed(new BID(Block::BED_BLOCK, 0, ItemIds::BED, \pocketmine\tile\Bed::class), "Bed Block")); + self::register(new Bedrock(new BID(Block::BEDROCK), "Bedrock")); + self::register(new Beetroot(new BID(Block::BEETROOT_BLOCK), "Beetroot Block")); + self::register(new BoneBlock(new BID(Block::BONE_BLOCK), "Bone Block")); + self::register(new Bookshelf(new BID(Block::BOOKSHELF), "Bookshelf")); + self::register(new BrewingStand(new BID(Block::BREWING_STAND_BLOCK, 0, ItemIds::BREWING_STAND), "Brewing Stand")); + self::register(new BrickStairs(new BID(Block::BRICK_STAIRS), "Brick Stairs")); + self::register(new Bricks(new BID(Block::BRICK_BLOCK), "Bricks")); + self::register(new BrownMushroom(new BID(Block::BROWN_MUSHROOM), "Brown Mushroom")); + self::register(new BrownMushroomBlock(new BID(Block::BROWN_MUSHROOM_BLOCK), "Brown Mushroom Block")); + self::register(new Cactus(new BID(Block::CACTUS), "Cactus")); + self::register(new Cake(new BID(Block::CAKE_BLOCK, 0, ItemIds::CAKE), "Cake")); + self::register(new Carrot(new BID(Block::CARROTS), "Carrot Block")); + self::register(new Chest(new BID(Block::CHEST, 0, null, \pocketmine\tile\Chest::class), "Chest")); + self::register(new Clay(new BID(Block::CLAY_BLOCK), "Clay Block")); + self::register(new Coal(new BID(Block::COAL_BLOCK), "Coal Block")); + self::register(new CoalOre(new BID(Block::COAL_ORE), "Coal Ore")); + self::register(new CoarseDirt(new BID(Block::DIRT, Dirt::COARSE), "Coarse Dirt")); + self::register(new Cobblestone(new BID(Block::COBBLESTONE), "Cobblestone")); + self::register(new Cobblestone(new BID(Block::MOSSY_COBBLESTONE), "Moss Stone")); + self::register(new CobblestoneStairs(new BID(Block::COBBLESTONE_STAIRS), "Cobblestone Stairs")); + self::register(new Cobweb(new BID(Block::COBWEB), "Cobweb")); + self::register(new CocoaBlock(new BID(Block::COCOA), "Cocoa Block")); + self::register(new CraftingTable(new BID(Block::CRAFTING_TABLE), "Crafting Table")); + self::register(new Dandelion(new BID(Block::DANDELION), "Dandelion")); + self::register($daylightSensor = new DaylightSensor(new BlockIdentifierFlattened(Block::DAYLIGHT_DETECTOR, Block::DAYLIGHT_DETECTOR_INVERTED), "Daylight Sensor")); + self::register((clone $daylightSensor)->setInverted()); //flattening hack + self::register(new DeadBush(new BID(Block::DEADBUSH), "Dead Bush")); + self::register(new DetectorRail(new BID(Block::DETECTOR_RAIL), "Detector Rail")); + self::register(new Diamond(new BID(Block::DIAMOND_BLOCK), "Diamond Block")); + self::register(new DiamondOre(new BID(Block::DIAMOND_ORE), "Diamond Ore")); + self::register(new Dirt(new BID(Block::DIRT, Dirt::NORMAL), "Dirt")); + self::register(new DoublePlant(new BID(Block::DOUBLE_PLANT, 0), "Sunflower")); + self::register(new DoublePlant(new BID(Block::DOUBLE_PLANT, 1), "Lilac")); + self::register(new DoublePlant(new BID(Block::DOUBLE_PLANT, 4), "Rose Bush")); + self::register(new DoublePlant(new BID(Block::DOUBLE_PLANT, 5), "Peony")); + self::register(new DoubleTallGrass(new BID(Block::DOUBLE_PLANT, 2), "Double Tallgrass")); + self::register(new DoubleTallGrass(new BID(Block::DOUBLE_PLANT, 3), "Large Fern")); + self::register(new Emerald(new BID(Block::EMERALD_BLOCK), "Emerald Block")); + self::register(new EmeraldOre(new BID(Block::EMERALD_ORE), "Emerald Ore")); + self::register(new EnchantingTable(new BID(Block::ENCHANTING_TABLE, 0, null, \pocketmine\tile\EnchantTable::class), "Enchanting Table")); + self::register(new EndPortalFrame(new BID(Block::END_PORTAL_FRAME), "End Portal Frame")); + self::register(new EndRod(new BID(Block::END_ROD), "End Rod")); + self::register(new EndStone(new BID(Block::END_STONE), "End Stone")); + self::register(new EndStoneBricks(new BID(Block::END_BRICKS), "End Stone Bricks")); + self::register(new EnderChest(new BID(Block::ENDER_CHEST, 0, null, \pocketmine\tile\EnderChest::class), "Ender Chest")); + self::register(new Farmland(new BID(Block::FARMLAND), "Farmland")); + self::register(new FenceGate(new BID(Block::ACACIA_FENCE_GATE), "Acacia Fence Gate")); + self::register(new FenceGate(new BID(Block::BIRCH_FENCE_GATE), "Birch Fence Gate")); + self::register(new FenceGate(new BID(Block::DARK_OAK_FENCE_GATE), "Dark Oak Fence Gate")); + self::register(new FenceGate(new BID(Block::OAK_FENCE_GATE), "Oak Fence Gate")); + self::register(new FenceGate(new BID(Block::JUNGLE_FENCE_GATE), "Jungle Fence Gate")); + self::register(new FenceGate(new BID(Block::SPRUCE_FENCE_GATE), "Spruce Fence Gate")); + self::register(new Fire(new BID(Block::FIRE), "Fire Block")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_ALLIUM), "Allium")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_AZURE_BLUET), "Azure Bluet")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_BLUE_ORCHID), "Blue Orchid")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_CORNFLOWER), "Cornflower")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_LILY_OF_THE_VALLEY), "Lily of the Valley")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_ORANGE_TULIP), "Orange Tulip")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_OXEYE_DAISY), "Oxeye Daisy")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_PINK_TULIP), "Pink Tulip")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_POPPY), "Poppy")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_RED_TULIP), "Red Tulip")); + self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_WHITE_TULIP), "White Tulip")); + self::register(new FlowerPot(new BID(Block::FLOWER_POT_BLOCK, 0, ItemIds::FLOWER_POT, \pocketmine\tile\FlowerPot::class), "Flower Pot")); + self::register($furnace = new Furnace(new BlockIdentifierFlattened(Block::FURNACE, Block::LIT_FURNACE, 0, null, \pocketmine\tile\Furnace::class), "Furnace")); + self::register((clone $furnace)->setLit()); //flattening hack + self::register(new Glass(new BID(Block::GLASS), "Glass")); + self::register(new GlassPane(new BID(Block::GLASS_PANE), "Glass Pane")); + self::register(new GlazedTerracotta(new BID(Block::BLACK_GLAZED_TERRACOTTA), "Black Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::BLUE_GLAZED_TERRACOTTA), "Blue Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::BROWN_GLAZED_TERRACOTTA), "Brown Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::CYAN_GLAZED_TERRACOTTA), "Cyan Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::GRAY_GLAZED_TERRACOTTA), "Grey Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::GREEN_GLAZED_TERRACOTTA), "Green Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::LIGHT_BLUE_GLAZED_TERRACOTTA), "Light Blue Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::LIME_GLAZED_TERRACOTTA), "Lime Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::MAGENTA_GLAZED_TERRACOTTA), "Magenta Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::ORANGE_GLAZED_TERRACOTTA), "Orange Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::PINK_GLAZED_TERRACOTTA), "Pink Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::PURPLE_GLAZED_TERRACOTTA), "Purple Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::RED_GLAZED_TERRACOTTA), "Red Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::SILVER_GLAZED_TERRACOTTA), "Light Grey Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::WHITE_GLAZED_TERRACOTTA), "White Glazed Terracotta")); + self::register(new GlazedTerracotta(new BID(Block::YELLOW_GLAZED_TERRACOTTA), "Yellow Glazed Terracotta")); + self::register(new GlowingObsidian(new BID(Block::GLOWINGOBSIDIAN), "Glowing Obsidian")); + self::register(new Glowstone(new BID(Block::GLOWSTONE), "Glowstone")); + self::register(new Gold(new BID(Block::GOLD_BLOCK), "Gold Block")); + self::register(new GoldOre(new BID(Block::GOLD_ORE), "Gold Ore")); + self::register(new Grass(new BID(Block::GRASS), "Grass")); + self::register(new GrassPath(new BID(Block::GRASS_PATH), "Grass Path")); + self::register(new Gravel(new BID(Block::GRAVEL), "Gravel")); + self::register(new HardenedClay(new BID(Block::HARDENED_CLAY), "Hardened Clay")); + self::register(new HardenedGlass(new BID(Block::HARD_GLASS), "Hardened Glass")); + self::register(new HardenedGlassPane(new BID(Block::HARD_GLASS_PANE), "Hardened Glass Pane")); + self::register(new HayBale(new BID(Block::HAY_BALE), "Hay Bale")); + self::register(new Ice(new BID(Block::ICE), "Ice")); + self::register(new InfoUpdate(new BID(Block::INFO_UPDATE), "update!")); + self::register(new InfoUpdate(new BID(Block::INFO_UPDATE2), "ate!upd")); + self::register(new InvisibleBedrock(new BID(Block::INVISIBLEBEDROCK), "Invisible Bedrock")); + self::register(new Iron(new BID(Block::IRON_BLOCK), "Iron Block")); + self::register(new IronBars(new BID(Block::IRON_BARS), "Iron Bars")); + self::register(new IronDoor(new BID(Block::IRON_DOOR_BLOCK, 0, ItemIds::IRON_DOOR), "Iron Door")); + self::register(new IronOre(new BID(Block::IRON_ORE), "Iron Ore")); + self::register(new IronTrapdoor(new BID(Block::IRON_TRAPDOOR), "Iron Trapdoor")); + self::register(new ItemFrame(new BID(Block::FRAME_BLOCK, 0, ItemIds::FRAME, \pocketmine\tile\ItemFrame::class), "Item Frame")); + self::register(new Ladder(new BID(Block::LADDER), "Ladder")); + self::register(new Lapis(new BID(Block::LAPIS_BLOCK), "Lapis Lazuli Block")); + self::register(new LapisOre(new BID(Block::LAPIS_ORE), "Lapis Lazuli Ore")); + self::register($lava = new Lava(new BlockIdentifierFlattened(Block::FLOWING_LAVA, Block::STILL_LAVA), "Lava")); + self::register((clone $lava)->setStill()); //flattening hack + self::register(new Lever(new BID(Block::LEVER), "Lever")); + self::register(new LitPumpkin(new BID(Block::JACK_O_LANTERN), "Jack o'Lantern")); + self::register(new Magma(new BID(Block::MAGMA), "Magma Block")); + self::register(new Melon(new BID(Block::MELON_BLOCK), "Melon Block")); + self::register(new MelonStem(new BID(Block::MELON_STEM, 0, ItemIds::MELON_SEEDS), "Melon Stem")); + self::register(new MonsterSpawner(new BID(Block::MOB_SPAWNER), "Monster Spawner")); + self::register(new Mycelium(new BID(Block::MYCELIUM), "Mycelium")); + self::register(new NetherBrick(new BID(Block::NETHER_BRICK_BLOCK), "Nether Bricks")); + self::register(new NetherBrick(new BID(Block::RED_NETHER_BRICK), "Red Nether Bricks")); + self::register(new NetherBrickFence(new BID(Block::NETHER_BRICK_FENCE), "Nether Brick Fence")); + self::register(new NetherBrickStairs(new BID(Block::NETHER_BRICK_STAIRS), "Nether Brick Stairs")); + self::register(new NetherQuartzOre(new BID(Block::NETHER_QUARTZ_ORE), "Nether Quartz Ore")); + self::register(new NetherReactor(new BID(Block::NETHERREACTOR), "Nether Reactor Core")); + self::register(new NetherWartBlock(new BID(Block::NETHER_WART_BLOCK), "Nether Wart Block")); + self::register(new NetherWartPlant(new BID(Block::NETHER_WART_PLANT, 0, ItemIds::NETHER_WART), "Nether Wart")); + self::register(new Netherrack(new BID(Block::NETHERRACK), "Netherrack")); + self::register(new NoteBlock(new BID(Block::NOTEBLOCK), "Note Block")); + self::register(new Obsidian(new BID(Block::OBSIDIAN), "Obsidian")); + self::register(new PackedIce(new BID(Block::PACKED_ICE), "Packed Ice")); + self::register(new Podzol(new BID(Block::PODZOL), "Podzol")); + self::register(new Potato(new BID(Block::POTATOES), "Potato Block")); + self::register(new PoweredRail(new BID(Block::GOLDEN_RAIL, BaseRail::STRAIGHT_NORTH_SOUTH), "Powered Rail")); + self::register(new Prismarine(new BID(Block::PRISMARINE, Prismarine::BRICKS), "Prismarine Bricks")); + self::register(new Prismarine(new BID(Block::PRISMARINE, Prismarine::DARK), "Dark Prismarine")); + self::register(new Prismarine(new BID(Block::PRISMARINE, Prismarine::NORMAL), "Prismarine")); + self::register(new Pumpkin(new BID(Block::PUMPKIN), "Pumpkin")); + self::register(new PumpkinStem(new BID(Block::PUMPKIN_STEM, 0, ItemIds::PUMPKIN_SEEDS), "Pumpkin Stem")); + self::register(new Purpur(new BID(Block::PURPUR_BLOCK), "Purpur Block")); + self::register(new class(new BID(Block::PURPUR_BLOCK, 2), "Purpur Pillar") extends Purpur{ use PillarRotationTrait; }); - self::register(new PurpurStairs()); - self::register(new Quartz(Block::QUARTZ_BLOCK, Quartz::NORMAL, "Quartz Block")); - self::register(new class(Block::QUARTZ_BLOCK, Quartz::CHISELED, "Chiseled Quartz Block") extends Quartz{ + self::register(new PurpurStairs(new BID(Block::PURPUR_STAIRS), "Purpur Stairs")); + self::register(new Quartz(new BID(Block::QUARTZ_BLOCK, Quartz::NORMAL), "Quartz Block")); + self::register(new class(new BID(Block::QUARTZ_BLOCK, Quartz::CHISELED), "Chiseled Quartz Block") extends Quartz{ use PillarRotationTrait; }); - self::register(new class(Block::QUARTZ_BLOCK, Quartz::PILLAR, "Quartz Pillar") extends Quartz{ + self::register(new class(new BID(Block::QUARTZ_BLOCK, Quartz::PILLAR), "Quartz Pillar") extends Quartz{ use PillarRotationTrait; }); - self::register(new Quartz(Block::QUARTZ_BLOCK, Quartz::SMOOTH, "Smooth Quartz Block")); //TODO: this has axis rotation in 1.9, unsure if a bug (https://bugs.mojang.com/browse/MCPE-39074) - self::register(new QuartzStairs()); - self::register(new Rail()); - self::register(new RedMushroom()); - self::register(new RedMushroomBlock()); - self::register(new RedSandstoneStairs()); - self::register(new Redstone()); - self::register(new RedstoneLamp()); - self::register((new RedstoneLamp())->setLit()); //flattening hack - self::register(new RedstoneOre()); - self::register((new RedstoneOre())->setLit()); //flattening hack - self::register(new RedstoneRepeater()); - self::register((new RedstoneRepeater())->setPowered()); - self::register(new RedstoneTorch()); - self::register((new RedstoneTorch())->setLit(false)); //flattening hack - self::register(new RedstoneWire()); - self::register(new Reserved6(Block::RESERVED6, 0, "reserved6")); - self::register(new Sand(Block::SAND, 0, "Sand")); - self::register(new Sand(Block::SAND, 1, "Red Sand")); - self::register(new SandstoneStairs()); - self::register(new SeaLantern()); - self::register(new SignPost()); - self::register(new Skull()); - self::register(new SmoothStone(Block::STONE, Stone::NORMAL, "Stone")); - self::register(new Snow()); - self::register(new SnowLayer()); - self::register(new SoulSand()); - self::register(new Sponge()); - self::register(new StandingBanner()); - self::register(new Stone(Block::STONE, Stone::ANDESITE, "Andesite")); - self::register(new Stone(Block::STONE, Stone::DIORITE, "Diorite")); - self::register(new Stone(Block::STONE, Stone::GRANITE, "Granite")); - self::register(new Stone(Block::STONE, Stone::POLISHED_ANDESITE, "Polished Andesite")); - self::register(new Stone(Block::STONE, Stone::POLISHED_DIORITE, "Polished Diorite")); - self::register(new Stone(Block::STONE, Stone::POLISHED_GRANITE, "Polished Granite")); - self::register(new StoneBrickStairs()); - self::register(new StoneBricks(Block::STONE_BRICKS, StoneBricks::CHISELED, "Chiseled Stone Bricks")); - self::register(new StoneBricks(Block::STONE_BRICKS, StoneBricks::CRACKED, "Cracked Stone Bricks")); - self::register(new StoneBricks(Block::STONE_BRICKS, StoneBricks::MOSSY, "Mossy Stone Bricks")); - self::register(new StoneBricks(Block::STONE_BRICKS, StoneBricks::NORMAL, "Stone Bricks")); - self::register(new StoneButton()); - self::register(new StonePressurePlate()); - self::register(new Stonecutter()); - self::register(new Sugarcane()); - self::register(new TNT()); - self::register(new TallGrass(Block::TALL_GRASS, 0, "Fern")); - self::register(new TallGrass(Block::TALL_GRASS, 1, "Tall Grass")); - self::register(new TallGrass(Block::TALL_GRASS, 2, "Fern")); - self::register(new TallGrass(Block::TALL_GRASS, 3, "Fern")); - self::register(new Torch(Block::COLORED_TORCH_BP, 0, "Blue Torch")); - self::register(new Torch(Block::COLORED_TORCH_BP, 8, "Purple Torch")); - self::register(new Torch(Block::COLORED_TORCH_RG, 0, "Red Torch")); - self::register(new Torch(Block::COLORED_TORCH_RG, 8, "Green Torch")); - self::register(new Torch(Block::TORCH, 0, "Torch")); - self::register(new Trapdoor()); - self::register(new TrappedChest()); - self::register(new Tripwire()); - self::register(new TripwireHook()); - self::register(new UnderwaterTorch(Block::UNDERWATER_TORCH, 0, "Underwater Torch")); - self::register(new Vine()); - self::register(new WallBanner()); - self::register(new WallSign()); - self::register(new Water()); - self::register((new Water())->setStill()); //flattening hack - self::register(new WaterLily()); - self::register(new WeightedPressurePlateHeavy()); - self::register(new WeightedPressurePlateLight()); - self::register(new Wheat()); - self::register(new WoodenButton()); - self::register(new WoodenDoor(Block::ACACIA_DOOR_BLOCK, 0, "Acacia Door", Item::ACACIA_DOOR)); - self::register(new WoodenDoor(Block::BIRCH_DOOR_BLOCK, 0, "Birch Door", Item::BIRCH_DOOR)); - self::register(new WoodenDoor(Block::DARK_OAK_DOOR_BLOCK, 0, "Dark Oak Door", Item::DARK_OAK_DOOR)); - self::register(new WoodenDoor(Block::JUNGLE_DOOR_BLOCK, 0, "Jungle Door", Item::JUNGLE_DOOR)); - self::register(new WoodenDoor(Block::OAK_DOOR_BLOCK, 0, "Oak Door", Item::OAK_DOOR)); - self::register(new WoodenDoor(Block::SPRUCE_DOOR_BLOCK, 0, "Spruce Door", Item::SPRUCE_DOOR)); - self::register(new WoodenPressurePlate()); - self::register(new WoodenStairs(Block::ACACIA_STAIRS, 0, "Acacia Stairs")); - self::register(new WoodenStairs(Block::BIRCH_STAIRS, 0, "Birch Stairs")); - self::register(new WoodenStairs(Block::DARK_OAK_STAIRS, 0, "Dark Oak Stairs")); - self::register(new WoodenStairs(Block::JUNGLE_STAIRS, 0, "Jungle Stairs")); - self::register(new WoodenStairs(Block::OAK_STAIRS, 0, "Oak Stairs")); - self::register(new WoodenStairs(Block::SPRUCE_STAIRS, 0, "Spruce Stairs")); + self::register(new Quartz(new BID(Block::QUARTZ_BLOCK, Quartz::SMOOTH), "Smooth Quartz Block")); //TODO: this has axis rotation in 1.9, unsure if a bug (https://bugs.mojang.com/browse/MCPE-39074) + self::register(new QuartzStairs(new BID(Block::QUARTZ_STAIRS), "Quartz Stairs")); + self::register(new Rail(new BID(Block::RAIL), "Rail")); + self::register(new RedMushroom(new BID(Block::RED_MUSHROOM), "Red Mushroom")); + self::register(new RedMushroomBlock(new BID(Block::RED_MUSHROOM_BLOCK), "Red Mushroom Block")); + self::register(new Redstone(new BID(Block::REDSTONE_BLOCK), "Redstone Block")); + self::register($redstoneLamp = new RedstoneLamp(new BlockIdentifierFlattened(Block::REDSTONE_LAMP, Block::LIT_REDSTONE_LAMP), "Redstone Lamp")); + self::register((clone $redstoneLamp)->setLit()); //flattening hack + self::register($redstoneOre = new RedstoneOre(new BlockIdentifierFlattened(Block::REDSTONE_ORE, Block::LIT_REDSTONE_ORE), "Redstone Ore")); + self::register((clone $redstoneOre)->setLit()); //flattening hack + self::register($repeater = new RedstoneRepeater(new BlockIdentifierFlattened(Block::UNPOWERED_REPEATER, Block::POWERED_REPEATER, 0, ItemIds::REPEATER), "Redstne Repeater")); + self::register((clone $repeater)->setPowered()); + self::register($redstoneTorch = new RedstoneTorch(new BlockIdentifierFlattened(Block::REDSTONE_TORCH, Block::UNLIT_REDSTONE_TORCH), "Redstone Torch")); + self::register((clone $redstoneTorch)->setLit(false)); //flattening hack + self::register(new RedstoneWire(new BID(Block::REDSTONE_WIRE, 0, ItemIds::REDSTONE), "Redstone")); + self::register(new Reserved6(new BID(Block::RESERVED6), "reserved6")); + self::register(new Sand(new BID(Block::SAND), "Sand")); + self::register(new Sand(new BID(Block::SAND, 1), "Red Sand")); + self::register(new SandstoneStairs(new BID(Block::RED_SANDSTONE_STAIRS), "Red Sandstone Stairs")); + self::register(new SandstoneStairs(new BID(Block::SANDSTONE_STAIRS), "Sandstone Stairs")); + self::register(new SeaLantern(new BID(Block::SEALANTERN), "Sea Lantern")); + self::register(new SignPost(new BID(Block::SIGN_POST, 0, ItemIds::SIGN, \pocketmine\tile\Sign::class), "Sign Post")); + self::register(new Skull(new BID(Block::MOB_HEAD_BLOCK, 0, null, \pocketmine\tile\Skull::class), "Mob Head")); + self::register(new SmoothStone(new BID(Block::STONE, Stone::NORMAL), "Stone")); + self::register(new Snow(new BID(Block::SNOW), "Snow Block")); + self::register(new SnowLayer(new BID(Block::SNOW_LAYER), "Snow Layer")); + self::register(new SoulSand(new BID(Block::SOUL_SAND), "Soul Sand")); + self::register(new Sponge(new BID(Block::SPONGE), "Sponge")); + self::register(new StandingBanner(new BID(Block::STANDING_BANNER, 0, ItemIds::BANNER, \pocketmine\tile\Banner::class), "Standing Banner")); + self::register(new Stone(new BID(Block::STONE, Stone::ANDESITE), "Andesite")); + self::register(new Stone(new BID(Block::STONE, Stone::DIORITE), "Diorite")); + self::register(new Stone(new BID(Block::STONE, Stone::GRANITE), "Granite")); + self::register(new Stone(new BID(Block::STONE, Stone::POLISHED_ANDESITE), "Polished Andesite")); + self::register(new Stone(new BID(Block::STONE, Stone::POLISHED_DIORITE), "Polished Diorite")); + self::register(new Stone(new BID(Block::STONE, Stone::POLISHED_GRANITE), "Polished Granite")); + self::register(new StoneBrickStairs(new BID(Block::STONE_BRICK_STAIRS), "Stone Brick Stairs")); + self::register(new StoneBricks(new BID(Block::STONEBRICK, StoneBricks::CHISELED), "Chiseled Stone Bricks")); + self::register(new StoneBricks(new BID(Block::STONEBRICK, StoneBricks::CRACKED), "Cracked Stone Bricks")); + self::register(new StoneBricks(new BID(Block::STONEBRICK, StoneBricks::MOSSY), "Mossy Stone Bricks")); + self::register(new StoneBricks(new BID(Block::STONEBRICK, StoneBricks::NORMAL), "Stone Bricks")); + self::register(new StoneButton(new BID(Block::STONE_BUTTON), "Stone Button")); + self::register(new StonePressurePlate(new BID(Block::STONE_PRESSURE_PLATE), "Stone Pressure Plate")); + self::register(new Stonecutter(new BID(Block::STONECUTTER), "Stonecutter")); + self::register(new Sugarcane(new BID(Block::REEDS_BLOCK, 0, ItemIds::REEDS), "Sugarcane")); + self::register(new TNT(new BID(Block::TNT), "TNT")); + self::register(new TallGrass(new BID(Block::TALLGRASS), "Fern")); + self::register(new TallGrass(new BID(Block::TALLGRASS, 1), "Tall Grass")); + self::register(new TallGrass(new BID(Block::TALLGRASS, 2), "Fern")); + self::register(new TallGrass(new BID(Block::TALLGRASS, 3), "Fern")); + self::register(new Torch(new BID(Block::COLORED_TORCH_BP), "Blue Torch")); + self::register(new Torch(new BID(Block::COLORED_TORCH_BP, 8), "Purple Torch")); + self::register(new Torch(new BID(Block::COLORED_TORCH_RG), "Red Torch")); + self::register(new Torch(new BID(Block::COLORED_TORCH_RG, 8), "Green Torch")); + self::register(new Torch(new BID(Block::TORCH), "Torch")); + self::register(new Trapdoor(new BID(Block::TRAPDOOR), "Wooden Trapdoor")); + self::register(new TrappedChest(new BID(Block::TRAPPED_CHEST, 0, null, \pocketmine\tile\Chest::class), "Trapped Chest")); + self::register(new Tripwire(new BID(Block::TRIPWIRE), "Tripwire")); + self::register(new TripwireHook(new BID(Block::TRIPWIRE_HOOK), "Tripwire Hook")); + self::register(new UnderwaterTorch(new BID(Block::UNDERWATER_TORCH), "Underwater Torch")); + self::register(new Vine(new BID(Block::VINE), "Vines")); + self::register(new WallBanner(new BID(Block::WALL_BANNER, 0, ItemIds::BANNER, \pocketmine\tile\Banner::class), "Wall Banner")); + self::register(new WallSign(new BID(Block::WALL_SIGN, 0, ItemIds::SIGN, \pocketmine\tile\Sign::class), "Wall Sign")); + self::register($water = new Water(new BlockIdentifierFlattened(Block::FLOWING_WATER, Block::STILL_WATER), "Water")); + self::register((clone $water)->setStill()); //flattening hack + self::register(new WaterLily(new BID(Block::LILY_PAD), "Lily Pad")); + self::register(new WeightedPressurePlateHeavy(new BID(Block::HEAVY_WEIGHTED_PRESSURE_PLATE), "Weighted Pressure Plate Heavy")); + self::register(new WeightedPressurePlateLight(new BID(Block::LIGHT_WEIGHTED_PRESSURE_PLATE), "Weighted Pressure Plate Light")); + self::register(new Wheat(new BID(Block::WHEAT_BLOCK), "Wheat Block")); + self::register(new WoodenButton(new BID(Block::WOODEN_BUTTON), "Wooden Button")); + self::register(new WoodenDoor(new BID(Block::ACACIA_DOOR_BLOCK, 0, ItemIds::ACACIA_DOOR), "Acacia Door")); + self::register(new WoodenDoor(new BID(Block::BIRCH_DOOR_BLOCK, 0, ItemIds::BIRCH_DOOR), "Birch Door")); + self::register(new WoodenDoor(new BID(Block::DARK_OAK_DOOR_BLOCK, 0, ItemIds::DARK_OAK_DOOR), "Dark Oak Door")); + self::register(new WoodenDoor(new BID(Block::JUNGLE_DOOR_BLOCK, 0, ItemIds::JUNGLE_DOOR), "Jungle Door")); + self::register(new WoodenDoor(new BID(Block::OAK_DOOR_BLOCK, 0, ItemIds::OAK_DOOR), "Oak Door")); + self::register(new WoodenDoor(new BID(Block::SPRUCE_DOOR_BLOCK, 0, ItemIds::SPRUCE_DOOR), "Spruce Door")); + self::register(new WoodenPressurePlate(new BID(Block::WOODEN_PRESSURE_PLATE), "Wooden Pressure Plate")); + self::register(new WoodenStairs(new BID(Block::ACACIA_STAIRS), "Acacia Stairs")); + self::register(new WoodenStairs(new BID(Block::BIRCH_STAIRS), "Birch Stairs")); + self::register(new WoodenStairs(new BID(Block::DARK_OAK_STAIRS), "Dark Oak Stairs")); + self::register(new WoodenStairs(new BID(Block::JUNGLE_STAIRS), "Jungle Stairs")); + self::register(new WoodenStairs(new BID(Block::OAK_STAIRS), "Oak Stairs")); + self::register(new WoodenStairs(new BID(Block::SPRUCE_STAIRS), "Spruce Stairs")); foreach(TreeType::getAll() as $treeType){ $magicNumber = $treeType->getMagicNumber(); $name = $treeType->getDisplayName(); - self::register(new Planks(Block::PLANKS, $magicNumber, $name . " Planks")); - self::register(new Sapling(Block::SAPLING, $magicNumber, $treeType, $name . " Sapling")); - self::register(new WoodenFence(Block::FENCE, $magicNumber, $name . " Fence")); + self::register(new Planks(new BID(Block::PLANKS, $magicNumber), $name . " Planks")); + self::register(new Sapling(new BID(Block::SAPLING, $magicNumber), $name . " Sapling", $treeType)); + self::register(new WoodenFence(new BID(Block::FENCE, $magicNumber), $name . " Fence")); //TODO: find a better way to deal with this split - self::register(new Leaves($magicNumber >= 4 ? Block::LEAVES2 : Block::LEAVES, $magicNumber & 0x03, $treeType, $name . " Leaves")); - self::register(new Log($magicNumber >= 4 ? Block::WOOD2 : Block::WOOD, $magicNumber & 0x03, $treeType, $name . " Log")); - self::register(new Wood($magicNumber >= 4 ? Block::WOOD2 : Block::WOOD, ($magicNumber & 0x03) | 0b1100, $treeType, $name . " Wood")); + self::register(new Leaves(new BID($magicNumber >= 4 ? Block::LEAVES2 : Block::LEAVES, $magicNumber & 0x03), $name . " Leaves", $treeType)); + self::register(new Log(new BID($magicNumber >= 4 ? Block::WOOD2 : Block::WOOD, $magicNumber & 0x03), $name . " Log", $treeType)); + self::register(new Wood(new BID($magicNumber >= 4 ? Block::WOOD2 : Block::WOOD, ($magicNumber & 0x03) | 0b1100), $name . " Wood", $treeType)); } static $sandstoneTypes = [ @@ -335,43 +336,43 @@ class BlockFactory{ Sandstone::SMOOTH => "Smooth " ]; foreach($sandstoneTypes as $variant => $prefix){ - self::register(new Sandstone(Block::SANDSTONE, $variant, $prefix . "Sandstone")); - self::register(new Sandstone(Block::RED_SANDSTONE, $variant, $prefix . "Red Sandstone")); + self::register(new Sandstone(new BID(Block::SANDSTONE, $variant), $prefix . "Sandstone")); + self::register(new Sandstone(new BID(Block::RED_SANDSTONE, $variant), $prefix . "Red Sandstone")); } foreach(DyeColor::getAll() as $color){ - self::register(new Carpet(Block::CARPET, $color->getMagicNumber(), $color->getDisplayName() . " Carpet")); - self::register(new Concrete(Block::CONCRETE, $color->getMagicNumber(), $color->getDisplayName() . " Concrete")); - self::register(new ConcretePowder(Block::CONCRETE_POWDER, $color->getMagicNumber(), $color->getDisplayName() . " Concrete Powder")); - self::register(new Glass(Block::STAINED_GLASS, $color->getMagicNumber(), $color->getDisplayName() . " Stained Glass")); - self::register(new GlassPane(Block::STAINED_GLASS_PANE, $color->getMagicNumber(), $color->getDisplayName() . " Stained Glass Pane")); - self::register(new HardenedClay(Block::STAINED_CLAY, $color->getMagicNumber(), $color->getDisplayName() . " Stained Clay")); - self::register(new HardenedGlass(Block::HARD_STAINED_GLASS, $color->getMagicNumber(), "Hardened " . $color->getDisplayName() . " Stained Glass")); - self::register(new HardenedGlassPane(Block::HARD_STAINED_GLASS_PANE, $color->getMagicNumber(), "Hardened " . $color->getDisplayName() . " Stained Glass Pane")); - self::register(new Wool(Block::WOOL, $color->getMagicNumber(), $color->getDisplayName() . " Wool")); + self::register(new Carpet(new BID(Block::CARPET, $color->getMagicNumber()), $color->getDisplayName() . " Carpet")); + self::register(new Concrete(new BID(Block::CONCRETE, $color->getMagicNumber()), $color->getDisplayName() . " Concrete")); + self::register(new ConcretePowder(new BID(Block::CONCRETE_POWDER, $color->getMagicNumber()), $color->getDisplayName() . " Concrete Powder")); + self::register(new Glass(new BID(Block::STAINED_GLASS, $color->getMagicNumber()), $color->getDisplayName() . " Stained Glass")); + self::register(new GlassPane(new BID(Block::STAINED_GLASS_PANE, $color->getMagicNumber()), $color->getDisplayName() . " Stained Glass Pane")); + self::register(new HardenedClay(new BID(Block::STAINED_CLAY, $color->getMagicNumber()), $color->getDisplayName() . " Stained Clay")); + self::register(new HardenedGlass(new BID(Block::HARD_STAINED_GLASS, $color->getMagicNumber()), "Hardened " . $color->getDisplayName() . " Stained Glass")); + self::register(new HardenedGlassPane(new BID(Block::HARD_STAINED_GLASS_PANE, $color->getMagicNumber()), "Hardened " . $color->getDisplayName() . " Stained Glass Pane")); + self::register(new Wool(new BID(Block::WOOL, $color->getMagicNumber()), $color->getDisplayName() . " Wool")); } /** @var Slab[] $slabTypes */ $slabTypes = [ - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 0, "Stone"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 1, "Sandstone"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 2, "Fake Wooden"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 3, "Cobblestone"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 4, "Brick"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 5, "Stone Brick"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 6, "Quartz"), - new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 7, "Nether Brick"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 0, "Red Sandstone"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 1, "Purpur"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 2, "Prismarine"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 3, "Dark Prismarine"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 4, "Prismarine Bricks"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 5, "Mossy Cobblestone"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 6, "Smooth Sandstone"), - new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 7, "Red Nether Brick") + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 0), "Stone"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 1), "Sandstone"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 2), "Fake Wooden"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 3), "Cobblestone"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 4), "Brick"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 5), "Stone Brick"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 6), "Quartz"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 7), "Nether Brick"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 0), "Red Sandstone"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 1), "Purpur"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 2), "Prismarine"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 3), "Dark Prismarine"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 4), "Prismarine Bricks"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 5), "Mossy Cobblestone"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 6), "Smooth Sandstone"), + new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 7), "Red Nether Brick") ]; foreach(TreeType::getAll() as $woodType){ - $slabTypes[] = new WoodenSlab(Block::WOODEN_SLAB, Block::DOUBLE_WOODEN_SLAB, $woodType->getMagicNumber(), $woodType->getDisplayName()); + $slabTypes[] = new WoodenSlab(new BlockIdentifierFlattened(Block::WOODEN_SLAB, Block::DOUBLE_WOODEN_SLAB, $woodType->getMagicNumber()), $woodType->getDisplayName()); } foreach($slabTypes as $type){ self::register($type); @@ -395,7 +396,7 @@ class BlockFactory{ CobblestoneWall::STONE_BRICK_WALL => "Stone Brick" ]; foreach($wallTypes as $magicNumber => $prefix){ - self::register(new CobblestoneWall(Block::COBBLESTONE_WALL, $magicNumber, $prefix . " Wall")); + self::register(new CobblestoneWall(new BID(Block::COBBLESTONE_WALL, $magicNumber), $prefix . " Wall")); } //TODO: minecraft:acacia_button @@ -533,8 +534,7 @@ class BlockFactory{ */ public static function register(Block $block, bool $override = false) : void{ $id = $block->getId(); - $variant = $block->getVariant(); - + $variant = $block->getIdInfo()->getVariant(); $stateMask = $block->getStateBitmask(); if(($variant & $stateMask) !== 0){ @@ -542,7 +542,7 @@ class BlockFactory{ } if(!$override and self::isRegistered($id, $variant)){ - throw new \InvalidArgumentException("Block registration conflicts with an existing block"); + throw new \InvalidArgumentException("Block registration $id:$variant conflicts with an existing block"); } for($m = $variant; $m <= ($variant | $stateMask); ++$m){ @@ -608,7 +608,7 @@ class BlockFactory{ } if($block === null){ - $block = new UnknownBlock($id, $meta); + $block = new UnknownBlock(new BID($id, $meta)); } if($pos !== null){ diff --git a/src/pocketmine/block/BlockIdentifier.php b/src/pocketmine/block/BlockIdentifier.php new file mode 100644 index 000000000..b5e855911 --- /dev/null +++ b/src/pocketmine/block/BlockIdentifier.php @@ -0,0 +1,71 @@ +blockId = $blockId; + $this->variant = $variant; + $this->itemId = $itemId; + $this->tileClass = $tileClass; + } + + /** + * @return int + */ + public function getBlockId() : int{ + return $this->blockId; + } + + /** + * @return int + */ + public function getVariant() : int{ + return $this->variant; + } + + /** + * @return int + */ + public function getItemId() : int{ + return $this->itemId ?? ($this->blockId > 255 ? 255 - $this->blockId : $this->blockId); + } + + /** + * @return string|null + */ + public function getTileClass() : ?string{ + return $this->tileClass; + } +} diff --git a/src/pocketmine/block/MossyCobblestone.php b/src/pocketmine/block/BlockIdentifierFlattened.php similarity index 65% rename from src/pocketmine/block/MossyCobblestone.php rename to src/pocketmine/block/BlockIdentifierFlattened.php index c9b83b6c8..026134d8a 100644 --- a/src/pocketmine/block/MossyCobblestone.php +++ b/src/pocketmine/block/BlockIdentifierFlattened.php @@ -23,12 +23,20 @@ declare(strict_types=1); namespace pocketmine\block; +class BlockIdentifierFlattened extends BlockIdentifier{ -class MossyCobblestone extends Cobblestone{ + /** @var int */ + private $secondId; - protected $id = self::MOSSY_COBBLESTONE; + public function __construct(int $blockId, int $secondId, int $variant = 0, ?int $itemId = null, ?string $tileClass = null){ + parent::__construct($blockId, $variant, $itemId, $tileClass); + $this->secondId = $secondId; + } - public function getName() : string{ - return "Moss Stone"; + /** + * @return int + */ + public function getSecondId() : int{ + return $this->secondId; } } diff --git a/src/pocketmine/block/BoneBlock.php b/src/pocketmine/block/BoneBlock.php index b8a183a1c..857e30df9 100644 --- a/src/pocketmine/block/BoneBlock.php +++ b/src/pocketmine/block/BoneBlock.php @@ -29,16 +29,6 @@ use pocketmine\item\TieredTool; class BoneBlock extends Solid{ use PillarRotationTrait; - protected $id = Block::BONE_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Bone Block"; - } - public function getHardness() : float{ return 2; } diff --git a/src/pocketmine/block/Bookshelf.php b/src/pocketmine/block/Bookshelf.php index 417109f64..3be95be1e 100644 --- a/src/pocketmine/block/Bookshelf.php +++ b/src/pocketmine/block/Bookshelf.php @@ -28,16 +28,6 @@ use pocketmine\item\ItemFactory; class Bookshelf extends Solid{ - protected $id = self::BOOKSHELF; - - public function __construct(){ - - } - - public function getName() : string{ - return "Bookshelf"; - } - public function getHardness() : float{ return 1.5; } diff --git a/src/pocketmine/block/BrewingStand.php b/src/pocketmine/block/BrewingStand.php index 21bbfed48..5651d1cc3 100644 --- a/src/pocketmine/block/BrewingStand.php +++ b/src/pocketmine/block/BrewingStand.php @@ -23,15 +23,10 @@ declare(strict_types=1); namespace pocketmine\block; -use pocketmine\item\Item; use pocketmine\item\TieredTool; class BrewingStand extends Transparent{ - protected $id = self::BREWING_STAND_BLOCK; - - protected $itemId = Item::BREWING_STAND; - /** @var bool */ protected $eastSlot = false; /** @var bool */ @@ -39,10 +34,6 @@ class BrewingStand extends Transparent{ /** @var bool */ protected $southwestSlot = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return ($this->eastSlot ? 0x01 : 0) | ($this->southwestSlot ? 0x02 : 0) | ($this->northwestSlot ? 0x04 : 0); } @@ -57,10 +48,6 @@ class BrewingStand extends Transparent{ return 0b111; } - public function getName() : string{ - return "Brewing Stand"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/BrickStairs.php b/src/pocketmine/block/BrickStairs.php index d8fd30393..aa5aebf17 100644 --- a/src/pocketmine/block/BrickStairs.php +++ b/src/pocketmine/block/BrickStairs.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class BrickStairs extends Stair{ - protected $id = self::BRICK_STAIRS; - - public function __construct(){ - - } - public function getHardness() : float{ return 2; } @@ -48,8 +42,4 @@ class BrickStairs extends Stair{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } - - public function getName() : string{ - return "Brick Stairs"; - } } diff --git a/src/pocketmine/block/Bricks.php b/src/pocketmine/block/Bricks.php index ee50e8d6a..c96efbb4e 100644 --- a/src/pocketmine/block/Bricks.php +++ b/src/pocketmine/block/Bricks.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class Bricks extends Solid{ - protected $id = self::BRICK_BLOCK; - - public function __construct(){ - - } - public function getHardness() : float{ return 2; } @@ -48,8 +42,4 @@ class Bricks extends Solid{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } - - public function getName() : string{ - return "Bricks"; - } } diff --git a/src/pocketmine/block/BrownMushroom.php b/src/pocketmine/block/BrownMushroom.php index dbb78e176..47b3bc7e6 100644 --- a/src/pocketmine/block/BrownMushroom.php +++ b/src/pocketmine/block/BrownMushroom.php @@ -25,12 +25,6 @@ namespace pocketmine\block; class BrownMushroom extends RedMushroom{ - protected $id = self::BROWN_MUSHROOM; - - public function getName() : string{ - return "Brown Mushroom"; - } - public function getLightLevel() : int{ return 1; } diff --git a/src/pocketmine/block/BrownMushroomBlock.php b/src/pocketmine/block/BrownMushroomBlock.php index 8c6b9819c..ac94d565c 100644 --- a/src/pocketmine/block/BrownMushroomBlock.php +++ b/src/pocketmine/block/BrownMushroomBlock.php @@ -28,12 +28,6 @@ use function mt_rand; class BrownMushroomBlock extends RedMushroomBlock{ - protected $id = Block::BROWN_MUSHROOM_BLOCK; - - public function getName() : string{ - return "Brown Mushroom Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ Item::get(Item::BROWN_MUSHROOM, 0, mt_rand(0, 2)) diff --git a/src/pocketmine/block/Button.php b/src/pocketmine/block/Button.php index bc472bbe3..1c4316d02 100644 --- a/src/pocketmine/block/Button.php +++ b/src/pocketmine/block/Button.php @@ -37,10 +37,6 @@ abstract class Button extends Flowable{ /** @var bool */ protected $powered = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->facing | ($this->powered ? 0x08 : 0); } diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index a99bdd5a3..0b16b7403 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -36,15 +36,9 @@ use pocketmine\Player; class Cactus extends Transparent{ - protected $id = self::CACTUS; - /** @var int */ protected $age = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->age; } @@ -65,10 +59,6 @@ class Cactus extends Transparent{ return true; } - public function getName() : string{ - return "Cactus"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ static $shrinkSize = 1 / 16; return AxisAlignedBB::one()->contract($shrinkSize, 0, $shrinkSize)->trim(Facing::UP, $shrinkSize); diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index 47d21e438..670e19e32 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -35,17 +35,9 @@ use pocketmine\Player; class Cake extends Transparent implements FoodSource{ - protected $id = self::CAKE_BLOCK; - - protected $itemId = Item::CAKE; - /** @var int */ protected $bites = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->bites; } @@ -62,10 +54,6 @@ class Cake extends Transparent implements FoodSource{ return 0.5; } - public function getName() : string{ - return "Cake"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ return AxisAlignedBB::one() ->contract(1 / 16, 0, 1 / 16) diff --git a/src/pocketmine/block/Carrot.php b/src/pocketmine/block/Carrot.php index 25297ae51..1e2c8b459 100644 --- a/src/pocketmine/block/Carrot.php +++ b/src/pocketmine/block/Carrot.php @@ -29,12 +29,6 @@ use function mt_rand; class Carrot extends Crops{ - protected $id = self::CARROT_BLOCK; - - public function getName() : string{ - return "Carrot Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::CARROT, 0, $this->age >= 7 ? mt_rand(1, 4) : 1) diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index b55a25828..173efc56a 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -33,15 +33,9 @@ use pocketmine\tile\Chest as TileChest; class Chest extends Transparent{ - protected $id = self::CHEST; - /** @var int */ protected $facing = Facing::NORTH; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->facing; } @@ -54,18 +48,10 @@ class Chest extends Transparent{ return 0b111; } - protected function getTileClass() : ?string{ - return TileChest::class; - } - public function getHardness() : float{ return 2.5; } - public function getName() : string{ - return "Chest"; - } - public function getToolType() : int{ return BlockToolType::TYPE_AXE; } diff --git a/src/pocketmine/block/Clay.php b/src/pocketmine/block/Clay.php index cc279b2be..c085dec93 100644 --- a/src/pocketmine/block/Clay.php +++ b/src/pocketmine/block/Clay.php @@ -28,12 +28,6 @@ use pocketmine\item\ItemFactory; class Clay extends Solid{ - protected $id = self::CLAY_BLOCK; - - public function __construct(){ - - } - public function getHardness() : float{ return 0.6; } @@ -42,10 +36,6 @@ class Clay extends Solid{ return BlockToolType::TYPE_SHOVEL; } - public function getName() : string{ - return "Clay Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::CLAY_BALL, 0, 4) diff --git a/src/pocketmine/block/Coal.php b/src/pocketmine/block/Coal.php index 36686bee7..0bef6e93a 100644 --- a/src/pocketmine/block/Coal.php +++ b/src/pocketmine/block/Coal.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class Coal extends Solid{ - protected $id = self::COAL_BLOCK; - - public function __construct(){ - - } - public function getHardness() : float{ return 5; } @@ -45,10 +39,6 @@ class Coal extends Solid{ return TieredTool::TIER_WOODEN; } - public function getName() : string{ - return "Coal Block"; - } - public function getFuelTime() : int{ return 16000; } diff --git a/src/pocketmine/block/CoalOre.php b/src/pocketmine/block/CoalOre.php index b935df923..aa98370a1 100644 --- a/src/pocketmine/block/CoalOre.php +++ b/src/pocketmine/block/CoalOre.php @@ -30,12 +30,6 @@ use function mt_rand; class CoalOre extends Solid{ - protected $id = self::COAL_ORE; - - public function __construct(){ - - } - public function getHardness() : float{ return 3; } @@ -48,10 +42,6 @@ class CoalOre extends Solid{ return TieredTool::TIER_WOODEN; } - public function getName() : string{ - return "Coal Ore"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::COAL) diff --git a/src/pocketmine/block/Cobblestone.php b/src/pocketmine/block/Cobblestone.php index 212a85875..988e6e464 100644 --- a/src/pocketmine/block/Cobblestone.php +++ b/src/pocketmine/block/Cobblestone.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class Cobblestone extends Solid{ - protected $id = self::COBBLESTONE; - - public function __construct(){ - - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } @@ -41,10 +35,6 @@ class Cobblestone extends Solid{ return TieredTool::TIER_WOODEN; } - public function getName() : string{ - return "Cobblestone"; - } - public function getHardness() : float{ return 2; } diff --git a/src/pocketmine/block/CobblestoneStairs.php b/src/pocketmine/block/CobblestoneStairs.php index b67c1a75d..780882e08 100644 --- a/src/pocketmine/block/CobblestoneStairs.php +++ b/src/pocketmine/block/CobblestoneStairs.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class CobblestoneStairs extends Stair{ - protected $id = self::COBBLESTONE_STAIRS; - - public function __construct(){ - - } - public function getHardness() : float{ return 2; } @@ -44,8 +38,4 @@ class CobblestoneStairs extends Stair{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } - - public function getName() : string{ - return "Cobblestone Stairs"; - } } diff --git a/src/pocketmine/block/Cobweb.php b/src/pocketmine/block/Cobweb.php index 4f424b348..a368851d9 100644 --- a/src/pocketmine/block/Cobweb.php +++ b/src/pocketmine/block/Cobweb.php @@ -29,20 +29,10 @@ use pocketmine\item\ItemFactory; class Cobweb extends Flowable{ - protected $id = self::COBWEB; - - public function __construct(){ - - } - public function hasEntityCollision() : bool{ return true; } - public function getName() : string{ - return "Cobweb"; - } - public function getHardness() : float{ return 4; } diff --git a/src/pocketmine/block/CocoaBlock.php b/src/pocketmine/block/CocoaBlock.php index 29b852d3c..18b7fd222 100644 --- a/src/pocketmine/block/CocoaBlock.php +++ b/src/pocketmine/block/CocoaBlock.php @@ -36,17 +36,11 @@ use function mt_rand; class CocoaBlock extends Transparent{ - protected $id = self::COCOA_BLOCK; - /** @var int */ protected $facing = Facing::NORTH; /** @var int */ protected $age = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return Bearing::fromFacing(Facing::opposite($this->facing)) | ($this->age << 2); } @@ -60,10 +54,6 @@ class CocoaBlock extends Transparent{ return 0b1111; } - public function getName() : string{ - return "Cocoa Block"; - } - public function getHardness() : float{ return 0.2; } diff --git a/src/pocketmine/block/ConcretePowder.php b/src/pocketmine/block/ConcretePowder.php index 3ff091612..9b030bd12 100644 --- a/src/pocketmine/block/ConcretePowder.php +++ b/src/pocketmine/block/ConcretePowder.php @@ -64,7 +64,7 @@ class ConcretePowder extends Solid implements Fallable{ continue; } if($this->getSide($i) instanceof Water){ - return BlockFactory::get(Block::CONCRETE, $this->variant); + return BlockFactory::get(Block::CONCRETE, $this->idInfo->getVariant()); } } diff --git a/src/pocketmine/block/CraftingTable.php b/src/pocketmine/block/CraftingTable.php index 113cfb6b6..369deab4e 100644 --- a/src/pocketmine/block/CraftingTable.php +++ b/src/pocketmine/block/CraftingTable.php @@ -30,20 +30,10 @@ use pocketmine\Player; class CraftingTable extends Solid{ - protected $id = self::CRAFTING_TABLE; - - public function __construct(){ - - } - public function getHardness() : float{ return 2.5; } - public function getName() : string{ - return "Crafting Table"; - } - public function getToolType() : int{ return BlockToolType::TYPE_AXE; } diff --git a/src/pocketmine/block/Crops.php b/src/pocketmine/block/Crops.php index 4a575a8f9..6d68af781 100644 --- a/src/pocketmine/block/Crops.php +++ b/src/pocketmine/block/Crops.php @@ -35,10 +35,6 @@ abstract class Crops extends Flowable{ /** @var int */ protected $age = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->age; } diff --git a/src/pocketmine/block/Dandelion.php b/src/pocketmine/block/Dandelion.php index 15be4a871..dba08c717 100644 --- a/src/pocketmine/block/Dandelion.php +++ b/src/pocketmine/block/Dandelion.php @@ -30,16 +30,6 @@ use pocketmine\Player; class Dandelion extends Flowable{ - protected $id = self::DANDELION; - - public function __construct(){ - - } - - public function getName() : string{ - return "Dandelion"; - } - public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); diff --git a/src/pocketmine/block/DaylightSensor.php b/src/pocketmine/block/DaylightSensor.php index cdf9814a3..7b60e6518 100644 --- a/src/pocketmine/block/DaylightSensor.php +++ b/src/pocketmine/block/DaylightSensor.php @@ -31,8 +31,8 @@ use pocketmine\math\Vector3; use pocketmine\Player; class DaylightSensor extends Transparent{ - - protected $itemId = self::DAYLIGHT_SENSOR; + /** @var BlockIdentifierFlattened */ + protected $idInfo; /** @var int */ protected $power = 0; @@ -40,12 +40,12 @@ class DaylightSensor extends Transparent{ /** @var bool */ protected $inverted = false; - public function __construct(){ - + public function __construct(BlockIdentifierFlattened $idInfo, string $name){ + parent::__construct($idInfo, $name); } public function getId() : int{ - return $this->inverted ? self::DAYLIGHT_SENSOR_INVERTED : self::DAYLIGHT_SENSOR; + return $this->inverted ? $this->idInfo->getSecondId() : parent::getId(); } protected function writeStateToMeta() : int{ @@ -74,10 +74,6 @@ class DaylightSensor extends Transparent{ return $this; } - public function getName() : string{ - return "Daylight Sensor"; - } - public function getHardness() : float{ return 0.2; } diff --git a/src/pocketmine/block/DeadBush.php b/src/pocketmine/block/DeadBush.php index 898327507..b1167f639 100644 --- a/src/pocketmine/block/DeadBush.php +++ b/src/pocketmine/block/DeadBush.php @@ -32,16 +32,6 @@ use function mt_rand; class DeadBush extends Flowable{ - protected $id = self::DEAD_BUSH; - - public function __construct(){ - - } - - public function getName() : string{ - return "Dead Bush"; - } - public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if(!$this->getSide(Facing::DOWN)->isTransparent()){ return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); diff --git a/src/pocketmine/block/DetectorRail.php b/src/pocketmine/block/DetectorRail.php index a4eddc910..91f29bcb5 100644 --- a/src/pocketmine/block/DetectorRail.php +++ b/src/pocketmine/block/DetectorRail.php @@ -25,11 +25,5 @@ namespace pocketmine\block; class DetectorRail extends RedstoneRail{ - protected $id = self::DETECTOR_RAIL; - - public function getName() : string{ - return "Detector Rail"; - } - //TODO } diff --git a/src/pocketmine/block/Diamond.php b/src/pocketmine/block/Diamond.php index 83a7935b6..5086a9d09 100644 --- a/src/pocketmine/block/Diamond.php +++ b/src/pocketmine/block/Diamond.php @@ -27,20 +27,10 @@ use pocketmine\item\TieredTool; class Diamond extends Solid{ - protected $id = self::DIAMOND_BLOCK; - - public function __construct(){ - - } - public function getHardness() : float{ return 5; } - public function getName() : string{ - return "Diamond Block"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/DiamondOre.php b/src/pocketmine/block/DiamondOre.php index 5aece22d3..9ff8273d7 100644 --- a/src/pocketmine/block/DiamondOre.php +++ b/src/pocketmine/block/DiamondOre.php @@ -30,20 +30,10 @@ use function mt_rand; class DiamondOre extends Solid{ - protected $id = self::DIAMOND_ORE; - - public function __construct(){ - - } - public function getHardness() : float{ return 3; } - public function getName() : string{ - return "Diamond Ore"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/Emerald.php b/src/pocketmine/block/Emerald.php index d67dc1dc7..fe85118f5 100644 --- a/src/pocketmine/block/Emerald.php +++ b/src/pocketmine/block/Emerald.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class Emerald extends Solid{ - protected $id = self::EMERALD_BLOCK; - - public function __construct(){ - - } - public function getHardness() : float{ return 5; } @@ -44,8 +38,4 @@ class Emerald extends Solid{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_IRON; } - - public function getName() : string{ - return "Emerald Block"; - } } diff --git a/src/pocketmine/block/EmeraldOre.php b/src/pocketmine/block/EmeraldOre.php index 590211310..7faf6986e 100644 --- a/src/pocketmine/block/EmeraldOre.php +++ b/src/pocketmine/block/EmeraldOre.php @@ -30,16 +30,6 @@ use function mt_rand; class EmeraldOre extends Solid{ - protected $id = self::EMERALD_ORE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Emerald Ore"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/EnchantingTable.php b/src/pocketmine/block/EnchantingTable.php index b8719674b..c2454f657 100644 --- a/src/pocketmine/block/EnchantingTable.php +++ b/src/pocketmine/block/EnchantingTable.php @@ -30,20 +30,9 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\Player; -use pocketmine\tile\EnchantTable as TileEnchantingTable; class EnchantingTable extends Transparent{ - protected $id = self::ENCHANTING_TABLE; - - public function __construct(){ - - } - - protected function getTileClass() : ?string{ - return TileEnchantingTable::class; - } - public function getHardness() : float{ return 5; } @@ -52,10 +41,6 @@ class EnchantingTable extends Transparent{ return 6000; } - public function getName() : string{ - return "Enchanting Table"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/EndPortalFrame.php b/src/pocketmine/block/EndPortalFrame.php index e15b55dc5..6d38c4bfa 100644 --- a/src/pocketmine/block/EndPortalFrame.php +++ b/src/pocketmine/block/EndPortalFrame.php @@ -33,17 +33,11 @@ use pocketmine\Player; class EndPortalFrame extends Solid{ - protected $id = self::END_PORTAL_FRAME; - /** @var int */ protected $facing = Facing::NORTH; /** @var bool */ protected $eye = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return Bearing::fromFacing($this->facing) | ($this->eye ? 0x04 : 0); } @@ -61,10 +55,6 @@ class EndPortalFrame extends Solid{ return 1; } - public function getName() : string{ - return "End Portal Frame"; - } - public function getHardness() : float{ return -1; } diff --git a/src/pocketmine/block/EndRod.php b/src/pocketmine/block/EndRod.php index aedfb03d5..2975f8f41 100644 --- a/src/pocketmine/block/EndRod.php +++ b/src/pocketmine/block/EndRod.php @@ -32,15 +32,9 @@ use pocketmine\Player; class EndRod extends Flowable{ - protected $id = Block::END_ROD; - /** @var int */ protected $facing = Facing::DOWN; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ if(Facing::axis($this->facing) === Facing::AXIS_Y){ return $this->facing; @@ -60,10 +54,6 @@ class EndRod extends Flowable{ return 0b111; } - public function getName() : string{ - return "End Rod"; - } - public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $this->facing = $face; if($blockClicked instanceof EndRod and $blockClicked->facing === $this->facing){ diff --git a/src/pocketmine/block/EndStone.php b/src/pocketmine/block/EndStone.php index 17953f776..c27b757db 100644 --- a/src/pocketmine/block/EndStone.php +++ b/src/pocketmine/block/EndStone.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class EndStone extends Solid{ - protected $id = self::END_STONE; - - public function __construct(){ - - } - - public function getName() : string{ - return "End Stone"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/EndStoneBricks.php b/src/pocketmine/block/EndStoneBricks.php index 0808f18b1..2028657cb 100644 --- a/src/pocketmine/block/EndStoneBricks.php +++ b/src/pocketmine/block/EndStoneBricks.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class EndStoneBricks extends Solid{ - protected $id = self::END_BRICKS; - - public function __construct(){ - - } - - public function getName() : string{ - return "End Stone Bricks"; - } - public function getHardness() : float{ return 0.8; } diff --git a/src/pocketmine/block/EnderChest.php b/src/pocketmine/block/EnderChest.php index c4d861086..59c3429c3 100644 --- a/src/pocketmine/block/EnderChest.php +++ b/src/pocketmine/block/EnderChest.php @@ -33,12 +33,6 @@ use pocketmine\tile\EnderChest as TileEnderChest; class EnderChest extends Chest{ - protected $id = self::ENDER_CHEST; - - protected function getTileClass() : ?string{ - return TileEnderChest::class; - } - public function getHardness() : float{ return 22.5; } @@ -51,10 +45,6 @@ class EnderChest extends Chest{ return 7; } - public function getName() : string{ - return "Ender Chest"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/Farmland.php b/src/pocketmine/block/Farmland.php index 2e862559e..6995d21e8 100644 --- a/src/pocketmine/block/Farmland.php +++ b/src/pocketmine/block/Farmland.php @@ -31,15 +31,9 @@ use pocketmine\math\Facing; class Farmland extends Transparent{ - protected $id = self::FARMLAND; - /** @var int */ protected $wetness = 0; //"moisture" blockstate property in PC - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->wetness; } @@ -52,10 +46,6 @@ class Farmland extends Transparent{ return 0b111; } - public function getName() : string{ - return "Farmland"; - } - public function getHardness() : float{ return 0.6; } diff --git a/src/pocketmine/block/Fire.php b/src/pocketmine/block/Fire.php index cae80261a..cf155413c 100644 --- a/src/pocketmine/block/Fire.php +++ b/src/pocketmine/block/Fire.php @@ -37,15 +37,9 @@ use function mt_rand; class Fire extends Flowable{ - protected $id = self::FIRE; - /** @var int */ protected $age = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->age; } @@ -62,10 +56,6 @@ class Fire extends Flowable{ return true; } - public function getName() : string{ - return "Fire Block"; - } - public function getLightLevel() : int{ return 15; } diff --git a/src/pocketmine/block/FlowerPot.php b/src/pocketmine/block/FlowerPot.php index 35968885b..4ff07b9a3 100644 --- a/src/pocketmine/block/FlowerPot.php +++ b/src/pocketmine/block/FlowerPot.php @@ -32,16 +32,9 @@ use pocketmine\tile\FlowerPot as TileFlowerPot; class FlowerPot extends Flowable{ - protected $id = self::FLOWER_POT_BLOCK; - protected $itemId = Item::FLOWER_POT; - /** @var bool */ protected $occupied = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->occupied ? 1 : 0; } @@ -54,14 +47,6 @@ class FlowerPot extends Flowable{ 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{ - return "Flower Pot"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ return AxisAlignedBB::one()->contract(3 / 16, 0, 3 / 16)->trim(Facing::UP, 5 / 8); } diff --git a/src/pocketmine/block/Furnace.php b/src/pocketmine/block/Furnace.php index 5f1449496..63e5c3948 100644 --- a/src/pocketmine/block/Furnace.php +++ b/src/pocketmine/block/Furnace.php @@ -32,20 +32,16 @@ use pocketmine\Player; use pocketmine\tile\Furnace as TileFurnace; class Furnace extends Solid{ - - protected $itemId = self::FURNACE; + /** @var BlockIdentifierFlattened */ + protected $idInfo; /** @var int */ protected $facing = Facing::NORTH; /** @var bool */ protected $lit = false; //this is set based on the blockID - public function __construct(){ - - } - public function getId() : int{ - return $this->lit ? Block::BURNING_FURNACE : Block::FURNACE; + return $this->lit ? $this->idInfo->getSecondId() : parent::getId(); } protected function writeStateToMeta() : int{ @@ -60,14 +56,6 @@ class Furnace extends Solid{ return 0b111; } - protected function getTileClass() : ?string{ - return TileFurnace::class; - } - - public function getName() : string{ - return "Furnace"; - } - public function getHardness() : float{ return 3.5; } diff --git a/src/pocketmine/block/GlowingObsidian.php b/src/pocketmine/block/GlowingObsidian.php index 51e81c450..ac0908a86 100644 --- a/src/pocketmine/block/GlowingObsidian.php +++ b/src/pocketmine/block/GlowingObsidian.php @@ -28,16 +28,6 @@ use pocketmine\item\TieredTool; class GlowingObsidian extends Solid{ - protected $id = self::GLOWING_OBSIDIAN; - - public function __construct(){ - - } - - public function getName() : string{ - return "Glowing Obsidian"; - } - public function getLightLevel() : int{ return 12; } diff --git a/src/pocketmine/block/Glowstone.php b/src/pocketmine/block/Glowstone.php index 11a59b2c1..54a3784c9 100644 --- a/src/pocketmine/block/Glowstone.php +++ b/src/pocketmine/block/Glowstone.php @@ -29,16 +29,6 @@ use function mt_rand; class Glowstone extends Transparent{ - protected $id = self::GLOWSTONE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Glowstone"; - } - public function getHardness() : float{ return 0.3; } diff --git a/src/pocketmine/block/Gold.php b/src/pocketmine/block/Gold.php index 8e6aa97c2..ce18ed78b 100644 --- a/src/pocketmine/block/Gold.php +++ b/src/pocketmine/block/Gold.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class Gold extends Solid{ - protected $id = self::GOLD_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Gold Block"; - } - public function getHardness() : float{ return 3; } diff --git a/src/pocketmine/block/GoldOre.php b/src/pocketmine/block/GoldOre.php index 9ef07f4cc..a4b465ee4 100644 --- a/src/pocketmine/block/GoldOre.php +++ b/src/pocketmine/block/GoldOre.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class GoldOre extends Solid{ - protected $id = self::GOLD_ORE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Gold Ore"; - } - public function getHardness() : float{ return 3; } diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index fadb3aaee..5d32b8bdc 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -37,16 +37,6 @@ use function mt_rand; class Grass extends Solid{ - protected $id = self::GRASS; - - public function __construct(){ - - } - - public function getName() : string{ - return "Grass"; - } - public function getHardness() : float{ return 0.6; } diff --git a/src/pocketmine/block/GrassPath.php b/src/pocketmine/block/GrassPath.php index 459ff721d..e41a4cf08 100644 --- a/src/pocketmine/block/GrassPath.php +++ b/src/pocketmine/block/GrassPath.php @@ -30,16 +30,6 @@ use pocketmine\math\Facing; class GrassPath extends Transparent{ - protected $id = self::GRASS_PATH; - - public function __construct(){ - - } - - public function getName() : string{ - return "Grass Path"; - } - public function getToolType() : int{ return BlockToolType::TYPE_SHOVEL; } diff --git a/src/pocketmine/block/Gravel.php b/src/pocketmine/block/Gravel.php index 939b0e801..b43848c46 100644 --- a/src/pocketmine/block/Gravel.php +++ b/src/pocketmine/block/Gravel.php @@ -32,16 +32,6 @@ use function mt_rand; class Gravel extends Solid implements Fallable{ use FallableTrait; - protected $id = self::GRAVEL; - - public function __construct(){ - - } - - public function getName() : string{ - return "Gravel"; - } - public function getHardness() : float{ return 0.6; } diff --git a/src/pocketmine/block/HayBale.php b/src/pocketmine/block/HayBale.php index e1bb4e19b..8a78ba8fe 100644 --- a/src/pocketmine/block/HayBale.php +++ b/src/pocketmine/block/HayBale.php @@ -28,16 +28,6 @@ use pocketmine\block\utils\PillarRotationTrait; class HayBale extends Solid{ use PillarRotationTrait; - protected $id = self::HAY_BALE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Hay Bale"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/Ice.php b/src/pocketmine/block/Ice.php index f499ea588..ccd3e72d8 100644 --- a/src/pocketmine/block/Ice.php +++ b/src/pocketmine/block/Ice.php @@ -29,16 +29,6 @@ use pocketmine\Player; class Ice extends Transparent{ - protected $id = self::ICE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Ice"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/InvisibleBedrock.php b/src/pocketmine/block/InvisibleBedrock.php index 689c90f6b..0b83d4fb1 100644 --- a/src/pocketmine/block/InvisibleBedrock.php +++ b/src/pocketmine/block/InvisibleBedrock.php @@ -27,16 +27,6 @@ use pocketmine\item\Item; class InvisibleBedrock extends Transparent{ - protected $id = self::INVISIBLE_BEDROCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Invisible Bedrock"; - } - public function getHardness() : float{ return -1; } diff --git a/src/pocketmine/block/Iron.php b/src/pocketmine/block/Iron.php index 0246fe536..fab064e31 100644 --- a/src/pocketmine/block/Iron.php +++ b/src/pocketmine/block/Iron.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class Iron extends Solid{ - protected $id = self::IRON_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Iron Block"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/IronBars.php b/src/pocketmine/block/IronBars.php index 755c0d12c..3cfeb036d 100644 --- a/src/pocketmine/block/IronBars.php +++ b/src/pocketmine/block/IronBars.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class IronBars extends Thin{ - protected $id = self::IRON_BARS; - - public function __construct(){ - - } - - public function getName() : string{ - return "Iron Bars"; - } - public function getHardness() : float{ return 5; } diff --git a/src/pocketmine/block/IronDoor.php b/src/pocketmine/block/IronDoor.php index c9da8160a..f735cdbcc 100644 --- a/src/pocketmine/block/IronDoor.php +++ b/src/pocketmine/block/IronDoor.php @@ -23,23 +23,10 @@ declare(strict_types=1); namespace pocketmine\block; -use pocketmine\item\Item; use pocketmine\item\TieredTool; class IronDoor extends Door{ - protected $id = self::IRON_DOOR_BLOCK; - - protected $itemId = Item::IRON_DOOR; - - public function __construct(){ - - } - - public function getName() : string{ - return "Iron Door"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/IronOre.php b/src/pocketmine/block/IronOre.php index c41c7518e..acff32ea6 100644 --- a/src/pocketmine/block/IronOre.php +++ b/src/pocketmine/block/IronOre.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class IronOre extends Solid{ - protected $id = self::IRON_ORE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Iron Ore"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/IronTrapdoor.php b/src/pocketmine/block/IronTrapdoor.php index cd52d5030..c807ef83d 100644 --- a/src/pocketmine/block/IronTrapdoor.php +++ b/src/pocketmine/block/IronTrapdoor.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class IronTrapdoor extends Trapdoor{ - protected $id = self::IRON_TRAPDOOR; - - public function getName() : string{ - return "Iron Trapdoor"; - } - public function getHardness() : float{ return 5; } diff --git a/src/pocketmine/block/ItemFrame.php b/src/pocketmine/block/ItemFrame.php index c685ea83a..3eff935ca 100644 --- a/src/pocketmine/block/ItemFrame.php +++ b/src/pocketmine/block/ItemFrame.php @@ -32,19 +32,12 @@ use pocketmine\tile\ItemFrame as TileItemFrame; use function lcg_value; class ItemFrame extends Flowable{ - protected $id = Block::ITEM_FRAME_BLOCK; - - protected $itemId = Item::ITEM_FRAME; /** @var int */ protected $facing = Facing::NORTH; /** @var bool */ protected $hasMap = false; //makes frame appear large if set - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return (5 - $this->facing) | ($this->hasMap ? 0x04 : 0); } @@ -58,14 +51,6 @@ class ItemFrame extends Flowable{ return 0b111; } - protected function getTileClass() : ?string{ - return TileItemFrame::class; - } - - public function getName() : string{ - return "Item Frame"; - } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $tile = $this->level->getTile($this); if($tile instanceof TileItemFrame){ diff --git a/src/pocketmine/block/Ladder.php b/src/pocketmine/block/Ladder.php index ab6fb6268..f99fdcc7a 100644 --- a/src/pocketmine/block/Ladder.php +++ b/src/pocketmine/block/Ladder.php @@ -33,15 +33,9 @@ use pocketmine\Player; class Ladder extends Transparent{ - protected $id = self::LADDER; - /** @var int */ protected $facing = Facing::NORTH; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->facing; } @@ -54,10 +48,6 @@ class Ladder extends Transparent{ return 0b111; } - public function getName() : string{ - return "Ladder"; - } - public function hasEntityCollision() : bool{ return true; } diff --git a/src/pocketmine/block/Lapis.php b/src/pocketmine/block/Lapis.php index 9af975e22..0e48fc4d2 100644 --- a/src/pocketmine/block/Lapis.php +++ b/src/pocketmine/block/Lapis.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class Lapis extends Solid{ - protected $id = self::LAPIS_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Lapis Lazuli Block"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/LapisOre.php b/src/pocketmine/block/LapisOre.php index 1337f6f0f..4c4326872 100644 --- a/src/pocketmine/block/LapisOre.php +++ b/src/pocketmine/block/LapisOre.php @@ -30,12 +30,6 @@ use function mt_rand; class LapisOre extends Solid{ - protected $id = self::LAPIS_ORE; - - public function __construct(){ - - } - public function getHardness() : float{ return 3; } @@ -48,10 +42,6 @@ class LapisOre extends Solid{ return TieredTool::TIER_STONE; } - public function getName() : string{ - return "Lapis Lazuli Ore"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::DYE, 4, mt_rand(4, 8)) diff --git a/src/pocketmine/block/Lava.php b/src/pocketmine/block/Lava.php index 2221d87cb..fb4d4f587 100644 --- a/src/pocketmine/block/Lava.php +++ b/src/pocketmine/block/Lava.php @@ -32,10 +32,6 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; class Lava extends Liquid{ - public function __construct(){ - parent::__construct(self::FLOWING_LAVA, self::STILL_LAVA, "Lava"); - } - public function getLightLevel() : int{ return 15; } diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 90aa6924c..85963e14f 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -42,8 +42,8 @@ class Leaves extends Transparent{ /** @var bool */ protected $checkDecay = false; - public function __construct(int $id, int $variant, TreeType $treeType, ?string $name = null){ - parent::__construct($id, $variant, $name); + public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType){ + parent::__construct($idInfo, $name); $this->treeType = $treeType; } diff --git a/src/pocketmine/block/Lever.php b/src/pocketmine/block/Lever.php index 16873081d..2f2423328 100644 --- a/src/pocketmine/block/Lever.php +++ b/src/pocketmine/block/Lever.php @@ -35,8 +35,6 @@ class Lever extends Flowable{ protected const SIDE = 1; protected const TOP = 2; - protected $id = self::LEVER; - /** @var int */ protected $position = self::BOTTOM; /** @var int */ @@ -44,10 +42,6 @@ class Lever extends Flowable{ /** @var bool */ protected $powered = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ if($this->position === self::BOTTOM){ $rotationMeta = Facing::axis($this->facing) === Facing::AXIS_Z ? 7 : 0; @@ -79,10 +73,6 @@ class Lever extends Flowable{ return 0b1111; } - public function getName() : string{ - return "Lever"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index 72d788991..d0280b012 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -37,8 +37,8 @@ use function lcg_value; use function min; abstract class Liquid extends Transparent{ - /** @var int */ - private $stillId; + /** @var BlockIdentifierFlattened */ + protected $idInfo; public $adjacentSources = 0; @@ -59,13 +59,12 @@ abstract class Liquid extends Transparent{ /** @var bool */ protected $still = false; - public function __construct(int $id, int $stillId, string $name){ - parent::__construct($id, 0, $name); - $this->stillId = $stillId; + public function __construct(BlockIdentifierFlattened $idInfo, string $name){ + parent::__construct($idInfo, $name); } public function getId() : int{ - return $this->still ? $this->stillId : parent::getId(); + return $this->still ? $this->idInfo->getSecondId() : parent::getId(); } protected function writeStateToMeta() : int{ diff --git a/src/pocketmine/block/LitPumpkin.php b/src/pocketmine/block/LitPumpkin.php index 5f9abf17e..dbc173bf9 100644 --- a/src/pocketmine/block/LitPumpkin.php +++ b/src/pocketmine/block/LitPumpkin.php @@ -25,13 +25,7 @@ namespace pocketmine\block; class LitPumpkin extends Pumpkin{ - protected $id = self::LIT_PUMPKIN; - public function getLightLevel() : int{ return 15; } - - public function getName() : string{ - return "Jack o'Lantern"; - } } diff --git a/src/pocketmine/block/Magma.php b/src/pocketmine/block/Magma.php index d246a4969..9d23abd34 100644 --- a/src/pocketmine/block/Magma.php +++ b/src/pocketmine/block/Magma.php @@ -30,16 +30,6 @@ use pocketmine\item\TieredTool; class Magma extends Solid{ - protected $id = Block::MAGMA; - - public function __construct(){ - - } - - public function getName() : string{ - return "Magma Block"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/Melon.php b/src/pocketmine/block/Melon.php index d9dc6e2d4..5498cb14d 100644 --- a/src/pocketmine/block/Melon.php +++ b/src/pocketmine/block/Melon.php @@ -29,16 +29,6 @@ use function mt_rand; class Melon extends Transparent{ - protected $id = self::MELON_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Melon Block"; - } - public function getHardness() : float{ return 1; } diff --git a/src/pocketmine/block/MelonStem.php b/src/pocketmine/block/MelonStem.php index 49646981d..4e50519fb 100644 --- a/src/pocketmine/block/MelonStem.php +++ b/src/pocketmine/block/MelonStem.php @@ -23,18 +23,8 @@ declare(strict_types=1); namespace pocketmine\block; -use pocketmine\item\Item; - class MelonStem extends Stem{ - protected $id = self::MELON_STEM; - - protected $itemId = Item::MELON_SEEDS; - - public function getName() : string{ - return "Melon Stem"; - } - protected function getPlant() : Block{ return BlockFactory::get(Block::MELON_BLOCK); } diff --git a/src/pocketmine/block/MonsterSpawner.php b/src/pocketmine/block/MonsterSpawner.php index bfe983cbb..f67957095 100644 --- a/src/pocketmine/block/MonsterSpawner.php +++ b/src/pocketmine/block/MonsterSpawner.php @@ -29,12 +29,6 @@ use function mt_rand; class MonsterSpawner extends Transparent{ - protected $id = self::MONSTER_SPAWNER; - - public function __construct(){ - - } - public function getHardness() : float{ return 5; } @@ -47,10 +41,6 @@ class MonsterSpawner extends Transparent{ return TieredTool::TIER_WOODEN; } - public function getName() : string{ - return "Monster Spawner"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return []; } diff --git a/src/pocketmine/block/Mycelium.php b/src/pocketmine/block/Mycelium.php index b6b98e64e..63d1c3653 100644 --- a/src/pocketmine/block/Mycelium.php +++ b/src/pocketmine/block/Mycelium.php @@ -31,16 +31,6 @@ use function mt_rand; class Mycelium extends Solid{ - protected $id = self::MYCELIUM; - - public function __construct(){ - - } - - public function getName() : string{ - return "Mycelium"; - } - public function getToolType() : int{ return BlockToolType::TYPE_SHOVEL; } diff --git a/src/pocketmine/block/NetherBrickFence.php b/src/pocketmine/block/NetherBrickFence.php index b8cd98afb..5b80e27fe 100644 --- a/src/pocketmine/block/NetherBrickFence.php +++ b/src/pocketmine/block/NetherBrickFence.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class NetherBrickFence extends Fence{ - protected $id = self::NETHER_BRICK_FENCE; - - public function __construct(){ - - } - public function getHardness() : float{ return 2; } @@ -44,8 +38,4 @@ class NetherBrickFence extends Fence{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } - - public function getName() : string{ - return "Nether Brick Fence"; - } } diff --git a/src/pocketmine/block/NetherBrickStairs.php b/src/pocketmine/block/NetherBrickStairs.php index f67c87795..8f5c16134 100644 --- a/src/pocketmine/block/NetherBrickStairs.php +++ b/src/pocketmine/block/NetherBrickStairs.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class NetherBrickStairs extends Stair{ - protected $id = self::NETHER_BRICK_STAIRS; - - public function __construct(){ - - } - - public function getName() : string{ - return "Nether Brick Stairs"; - } - public function getHardness() : float{ return 2; } diff --git a/src/pocketmine/block/NetherQuartzOre.php b/src/pocketmine/block/NetherQuartzOre.php index 814f11f6a..fc6cbaa3a 100644 --- a/src/pocketmine/block/NetherQuartzOre.php +++ b/src/pocketmine/block/NetherQuartzOre.php @@ -30,16 +30,6 @@ use function mt_rand; class NetherQuartzOre extends Solid{ - protected $id = Block::NETHER_QUARTZ_ORE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Nether Quartz Ore"; - } - public function getHardness() : float{ return 3; } diff --git a/src/pocketmine/block/NetherReactor.php b/src/pocketmine/block/NetherReactor.php index 92c2c0bb2..1ec7ab236 100644 --- a/src/pocketmine/block/NetherReactor.php +++ b/src/pocketmine/block/NetherReactor.php @@ -33,15 +33,9 @@ class NetherReactor extends Solid{ protected const STATE_ACTIVE = 1; protected const STATE_USED = 2; - protected $id = Block::NETHER_REACTOR; - /** @var int */ protected $state = self::STATE_INACTIVE; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->state; } @@ -54,10 +48,6 @@ class NetherReactor extends Solid{ return 0b11; } - public function getName() : string{ - return "Nether Reactor Core"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/NetherWartBlock.php b/src/pocketmine/block/NetherWartBlock.php index 21cdc6f50..2460a69c3 100644 --- a/src/pocketmine/block/NetherWartBlock.php +++ b/src/pocketmine/block/NetherWartBlock.php @@ -25,16 +25,6 @@ namespace pocketmine\block; class NetherWartBlock extends Solid{ - protected $id = Block::NETHER_WART_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Nether Wart Block"; - } - public function getHardness() : float{ return 1; } diff --git a/src/pocketmine/block/NetherWartPlant.php b/src/pocketmine/block/NetherWartPlant.php index 2aa9fdd6a..9489847e9 100644 --- a/src/pocketmine/block/NetherWartPlant.php +++ b/src/pocketmine/block/NetherWartPlant.php @@ -27,24 +27,16 @@ namespace pocketmine\block; use pocketmine\block\utils\BlockDataValidator; use pocketmine\event\block\BlockGrowEvent; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\Player; use function mt_rand; class NetherWartPlant extends Flowable{ - protected $id = Block::NETHER_WART_PLANT; - - protected $itemId = Item::NETHER_WART; /** @var int */ protected $age = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->age; } @@ -57,10 +49,6 @@ class NetherWartPlant extends Flowable{ return 0b11; } - public function getName() : string{ - return "Nether Wart"; - } - public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); if($down->getId() === Block::SOUL_SAND){ @@ -94,7 +82,7 @@ class NetherWartPlant extends Flowable{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get($this->getItemId(), 0, ($this->age === 3 ? mt_rand(2, 4) : 1)) + $this->getItem()->setCount($this->age === 3 ? mt_rand(2, 4) : 1) ]; } diff --git a/src/pocketmine/block/Netherrack.php b/src/pocketmine/block/Netherrack.php index 1a79ea9f9..34ca389db 100644 --- a/src/pocketmine/block/Netherrack.php +++ b/src/pocketmine/block/Netherrack.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class Netherrack extends Solid{ - protected $id = self::NETHERRACK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Netherrack"; - } - public function getHardness() : float{ return 0.4; } diff --git a/src/pocketmine/block/NoteBlock.php b/src/pocketmine/block/NoteBlock.php index 4c30cb60f..113d6accf 100644 --- a/src/pocketmine/block/NoteBlock.php +++ b/src/pocketmine/block/NoteBlock.php @@ -25,16 +25,6 @@ namespace pocketmine\block; class NoteBlock extends Solid{ - protected $id = self::NOTE_BLOCK; - - public function __construct(){ - - } - - public function getName() : string{ - return "Note Block"; - } - public function getFuelTime() : int{ return 300; } diff --git a/src/pocketmine/block/Obsidian.php b/src/pocketmine/block/Obsidian.php index ba821ec1b..e204784cf 100644 --- a/src/pocketmine/block/Obsidian.php +++ b/src/pocketmine/block/Obsidian.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class Obsidian extends Solid{ - protected $id = self::OBSIDIAN; - - public function __construct(){ - - } - - public function getName() : string{ - return "Obsidian"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/PackedIce.php b/src/pocketmine/block/PackedIce.php index 6ca48c390..1455c3148 100644 --- a/src/pocketmine/block/PackedIce.php +++ b/src/pocketmine/block/PackedIce.php @@ -25,16 +25,6 @@ namespace pocketmine\block; class PackedIce extends Solid{ - protected $id = self::PACKED_ICE; - - public function __construct(){ - - } - - public function getName() : string{ - return "Packed Ice"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/Podzol.php b/src/pocketmine/block/Podzol.php index be44cf1b4..0cfa1ccda 100644 --- a/src/pocketmine/block/Podzol.php +++ b/src/pocketmine/block/Podzol.php @@ -25,20 +25,10 @@ namespace pocketmine\block; class Podzol extends Solid{ - protected $id = self::PODZOL; - - public function __construct(){ - - } - public function getToolType() : int{ return BlockToolType::TYPE_SHOVEL; } - public function getName() : string{ - return "Podzol"; - } - public function getHardness() : float{ return 2.5; } diff --git a/src/pocketmine/block/Potato.php b/src/pocketmine/block/Potato.php index 5faf4d11a..62aa45caf 100644 --- a/src/pocketmine/block/Potato.php +++ b/src/pocketmine/block/Potato.php @@ -29,12 +29,6 @@ use function mt_rand; class Potato extends Crops{ - protected $id = self::POTATO_BLOCK; - - public function getName() : string{ - return "Potato Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::POTATO, 0, $this->age >= 7 ? mt_rand(1, 4) : 1) diff --git a/src/pocketmine/block/PoweredRail.php b/src/pocketmine/block/PoweredRail.php index ed7b1a00b..0a66be5be 100644 --- a/src/pocketmine/block/PoweredRail.php +++ b/src/pocketmine/block/PoweredRail.php @@ -24,9 +24,4 @@ declare(strict_types=1); namespace pocketmine\block; class PoweredRail extends RedstoneRail{ - protected $id = self::POWERED_RAIL; - - public function getName() : string{ - return "Powered Rail"; - } } diff --git a/src/pocketmine/block/Pumpkin.php b/src/pocketmine/block/Pumpkin.php index 5e4832418..7bd2e08b9 100644 --- a/src/pocketmine/block/Pumpkin.php +++ b/src/pocketmine/block/Pumpkin.php @@ -32,15 +32,9 @@ use pocketmine\Player; class Pumpkin extends Solid{ - protected $id = self::PUMPKIN; - /** @var int */ protected $facing = Facing::NORTH; - public function __construct(){ - - } - public function readStateFromMeta(int $meta) : void{ $this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03); } @@ -61,10 +55,6 @@ class Pumpkin extends Solid{ return BlockToolType::TYPE_AXE; } - public function getName() : string{ - return "Pumpkin"; - } - public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($player !== null){ $this->facing = Facing::opposite($player->getHorizontalFacing()); diff --git a/src/pocketmine/block/PumpkinStem.php b/src/pocketmine/block/PumpkinStem.php index fa13fcc41..3c28e00e8 100644 --- a/src/pocketmine/block/PumpkinStem.php +++ b/src/pocketmine/block/PumpkinStem.php @@ -23,18 +23,8 @@ declare(strict_types=1); namespace pocketmine\block; -use pocketmine\item\Item; - class PumpkinStem extends Stem{ - protected $id = self::PUMPKIN_STEM; - - protected $itemId = Item::PUMPKIN_SEEDS; - - public function getName() : string{ - return "Pumpkin Stem"; - } - protected function getPlant() : Block{ return BlockFactory::get(Block::PUMPKIN); } diff --git a/src/pocketmine/block/PurpurStairs.php b/src/pocketmine/block/PurpurStairs.php index 49409be4f..4ba243108 100644 --- a/src/pocketmine/block/PurpurStairs.php +++ b/src/pocketmine/block/PurpurStairs.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class PurpurStairs extends Stair{ - protected $id = self::PURPUR_STAIRS; - - public function __construct(){ - - } - - public function getName() : string{ - return "Purpur Stairs"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/QuartzStairs.php b/src/pocketmine/block/QuartzStairs.php index 56b93156d..db910f0e8 100644 --- a/src/pocketmine/block/QuartzStairs.php +++ b/src/pocketmine/block/QuartzStairs.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class QuartzStairs extends Stair{ - protected $id = self::QUARTZ_STAIRS; - - public function __construct(){ - - } - public function getHardness() : float{ return 0.8; } @@ -44,8 +38,4 @@ class QuartzStairs extends Stair{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } - - public function getName() : string{ - return "Quartz Stairs"; - } } diff --git a/src/pocketmine/block/Rail.php b/src/pocketmine/block/Rail.php index cc78c4c40..93b9a0f9f 100644 --- a/src/pocketmine/block/Rail.php +++ b/src/pocketmine/block/Rail.php @@ -52,12 +52,6 @@ class Rail extends BaseRail{ ] ]; - protected $id = self::RAIL; - - public function getName() : string{ - return "Rail"; - } - protected function getMetaForState(array $connections) : int{ try{ return self::searchState($connections, self::CURVE_CONNECTIONS); diff --git a/src/pocketmine/block/RedMushroom.php b/src/pocketmine/block/RedMushroom.php index be4d6e1bb..8f23f1c48 100644 --- a/src/pocketmine/block/RedMushroom.php +++ b/src/pocketmine/block/RedMushroom.php @@ -30,16 +30,6 @@ use pocketmine\Player; class RedMushroom extends Flowable{ - protected $id = self::RED_MUSHROOM; - - public function __construct(){ - - } - - public function getName() : string{ - return "Red Mushroom"; - } - public function ticksRandomly() : bool{ return true; } diff --git a/src/pocketmine/block/RedMushroomBlock.php b/src/pocketmine/block/RedMushroomBlock.php index c94018ef2..42403f67d 100644 --- a/src/pocketmine/block/RedMushroomBlock.php +++ b/src/pocketmine/block/RedMushroomBlock.php @@ -28,8 +28,6 @@ use function mt_rand; class RedMushroomBlock extends Solid{ - protected $id = Block::RED_MUSHROOM_BLOCK; - /** * @var int * In PC they have blockstate properties for each of the sides (pores/not pores). Unfortunately, we can't support @@ -39,10 +37,6 @@ class RedMushroomBlock extends Solid{ */ protected $rotationData = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->rotationData; } @@ -55,10 +49,6 @@ class RedMushroomBlock extends Solid{ return 0b1111; } - public function getName() : string{ - return "Red Mushroom Block"; - } - public function getHardness() : float{ return 0.2; } diff --git a/src/pocketmine/block/RedSandstoneStairs.php b/src/pocketmine/block/RedSandstoneStairs.php deleted file mode 100644 index 5c1471f69..000000000 --- a/src/pocketmine/block/RedSandstoneStairs.php +++ /dev/null @@ -1,33 +0,0 @@ -lit ? self::LIT_REDSTONE_LAMP : self::REDSTONE_LAMP; + return $this->lit ? $this->idInfo->getSecondId() : parent::getId(); } public function isLit() : bool{ @@ -56,10 +57,6 @@ class RedstoneLamp extends Solid{ return $this->lit ? 15 : 0; } - public function getName() : string{ - return "Redstone Lamp"; - } - public function getHardness() : float{ return 0.3; } diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 3a452c21e..306ae7db0 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -31,22 +31,18 @@ use pocketmine\Player; use function mt_rand; class RedstoneOre extends Solid{ - - protected $itemId = self::REDSTONE_ORE; + /** @var BlockIdentifierFlattened */ + protected $idInfo; /** @var bool */ protected $lit = false; - public function __construct(){ - + public function __construct(BlockIdentifierFlattened $idInfo, string $name){ + parent::__construct($idInfo, $name); } public function getId() : int{ - return $this->lit ? self::GLOWING_REDSTONE_ORE : self::REDSTONE_ORE; - } - - public function getName() : string{ - return "Redstone Ore"; + return $this->lit ? $this->idInfo->getSecondId() : parent::getId(); } public function getHardness() : float{ diff --git a/src/pocketmine/block/RedstoneRepeater.php b/src/pocketmine/block/RedstoneRepeater.php index 4917890d9..29c658f32 100644 --- a/src/pocketmine/block/RedstoneRepeater.php +++ b/src/pocketmine/block/RedstoneRepeater.php @@ -32,8 +32,8 @@ use pocketmine\math\Vector3; use pocketmine\Player; class RedstoneRepeater extends Flowable{ - /** @var int */ - protected $itemId = Item::REPEATER; + /** @var BlockIdentifierFlattened */ + protected $idInfo; /** @var bool */ protected $powered = false; @@ -42,12 +42,12 @@ class RedstoneRepeater extends Flowable{ /** @var int */ protected $delay = 1; - public function __construct(){ - + public function __construct(BlockIdentifierFlattened $idInfo, string $name){ + parent::__construct($idInfo, $name); } public function getId() : int{ - return $this->powered ? Block::POWERED_REPEATER : Block::UNPOWERED_REPEATER; + return $this->powered ? $this->idInfo->getSecondId() : parent::getId(); } public function readStateFromMeta(int $meta) : void{ @@ -63,10 +63,6 @@ class RedstoneRepeater extends Flowable{ return 0b1111; } - public function getName() : string{ - return "Redstone Repeater"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ return AxisAlignedBB::one()->trim(Facing::UP, 7 / 8); } diff --git a/src/pocketmine/block/RedstoneTorch.php b/src/pocketmine/block/RedstoneTorch.php index b9956e37c..44119dc26 100644 --- a/src/pocketmine/block/RedstoneTorch.php +++ b/src/pocketmine/block/RedstoneTorch.php @@ -25,21 +25,18 @@ namespace pocketmine\block; class RedstoneTorch extends Torch{ - protected $itemId = self::REDSTONE_TORCH; + /** @var BlockIdentifierFlattened */ + protected $idInfo; /** @var bool */ protected $lit = true; - public function __construct(){ - parent::__construct(self::REDSTONE_TORCH, 0, "Redstone Torch", self::REDSTONE_TORCH); + public function __construct(BlockIdentifierFlattened $idInfo, string $name){ + parent::__construct($idInfo, $name); } public function getId() : int{ - return $this->lit ? self::REDSTONE_TORCH : self::UNLIT_REDSTONE_TORCH; - } - - public function getName() : string{ - return "Redstone Torch"; + return $this->lit ? parent::getId() : $this->idInfo->getSecondId(); } public function isLit() : bool{ diff --git a/src/pocketmine/block/RedstoneWire.php b/src/pocketmine/block/RedstoneWire.php index 6ad98d589..e8d2a3b7d 100644 --- a/src/pocketmine/block/RedstoneWire.php +++ b/src/pocketmine/block/RedstoneWire.php @@ -24,21 +24,12 @@ declare(strict_types=1); namespace pocketmine\block; use pocketmine\block\utils\BlockDataValidator; -use pocketmine\item\Item; class RedstoneWire extends Flowable{ - /** @var int */ - protected $id = Block::REDSTONE_WIRE; - /** @var int */ - protected $itemId = Item::REDSTONE; /** @var int */ protected $power = 0; - public function __construct(){ - - } - public function readStateFromMeta(int $meta) : void{ $this->power = BlockDataValidator::readBoundedInt("power", $meta, 0, 15); } @@ -51,10 +42,6 @@ class RedstoneWire extends Flowable{ return 0b1111; } - public function getName() : string{ - return "Redstone"; - } - public function readStateFromWorld() : void{ parent::readStateFromWorld(); //TODO: check connections to nearby redstone components diff --git a/src/pocketmine/block/SandstoneStairs.php b/src/pocketmine/block/SandstoneStairs.php index aeeb0152e..19056fa73 100644 --- a/src/pocketmine/block/SandstoneStairs.php +++ b/src/pocketmine/block/SandstoneStairs.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class SandstoneStairs extends Stair{ - protected $id = self::SANDSTONE_STAIRS; - - public function __construct(){ - - } - public function getHardness() : float{ return 0.8; } @@ -44,8 +38,4 @@ class SandstoneStairs extends Stair{ public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } - - public function getName() : string{ - return "Sandstone Stairs"; - } } diff --git a/src/pocketmine/block/Sapling.php b/src/pocketmine/block/Sapling.php index e99ce48f1..9e07f7ebc 100644 --- a/src/pocketmine/block/Sapling.php +++ b/src/pocketmine/block/Sapling.php @@ -39,8 +39,8 @@ class Sapling extends Flowable{ /** @var TreeType */ private $treeType; - public function __construct(int $id, int $variant, TreeType $treeType, ?string $name = null, int $itemId = null){ - parent::__construct($id, $variant, $name, $itemId); + public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType){ + parent::__construct($idInfo, $name); $this->treeType = $treeType; } diff --git a/src/pocketmine/block/SeaLantern.php b/src/pocketmine/block/SeaLantern.php index 3d0e3009f..09947580e 100644 --- a/src/pocketmine/block/SeaLantern.php +++ b/src/pocketmine/block/SeaLantern.php @@ -28,16 +28,6 @@ use pocketmine\item\ItemFactory; class SeaLantern extends Transparent{ - protected $id = self::SEA_LANTERN; - - public function __construct(){ - - } - - public function getName() : string{ - return "Sea Lantern"; - } - public function getHardness() : float{ return 0.3; } diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index e069472ea..8cd0c16d1 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -28,22 +28,13 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\Player; -use pocketmine\tile\Sign as TileSign; use function floor; class SignPost extends Transparent{ - protected $id = self::SIGN_POST; - - protected $itemId = Item::SIGN; - /** @var int */ protected $rotation = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->rotation; } @@ -56,10 +47,6 @@ class SignPost extends Transparent{ return 0b1111; } - protected function getTileClass() : ?string{ - return TileSign::class; - } - public function getHardness() : float{ return 1; } @@ -68,10 +55,6 @@ class SignPost extends Transparent{ return false; } - public function getName() : string{ - return "Sign Post"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ return null; } diff --git a/src/pocketmine/block/Skull.php b/src/pocketmine/block/Skull.php index acce6c4c4..1b14ac161 100644 --- a/src/pocketmine/block/Skull.php +++ b/src/pocketmine/block/Skull.php @@ -35,8 +35,6 @@ use function floor; class Skull extends Flowable{ - protected $id = self::SKULL_BLOCK; - /** @var int */ protected $facing = Facing::NORTH; @@ -44,10 +42,6 @@ class Skull extends Flowable{ /** @var int */ protected $rotation = 0; //TODO: split this into floor skull and wall skull handling - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->facing; } @@ -69,10 +63,6 @@ class Skull extends Flowable{ } } - protected function getTileClass() : ?string{ - return TileSkull::class; - } - public function writeStateToWorld() : void{ parent::writeStateToWorld(); //extra block properties storage hack @@ -87,10 +77,6 @@ class Skull extends Flowable{ return 1; } - public function getName() : string{ - return "Mob Head"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ //TODO: different bounds depending on attached face return AxisAlignedBB::one()->contract(0.25, 0, 0.25)->trim(Facing::UP, 0.5); diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 92cb7d791..311802e7a 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -31,20 +31,19 @@ use pocketmine\math\Vector3; use pocketmine\Player; abstract class Slab extends Transparent{ - /** @var int */ - protected $doubleId; + /** @var BlockIdentifierFlattened */ + protected $idInfo; /** @var SlabType */ protected $slabType; - public function __construct(int $id, int $doubleId, int $variant = 0, ?string $name = null){ - parent::__construct($id, $variant, $name . " Slab", $id); - $this->doubleId = $doubleId; + public function __construct(BlockIdentifierFlattened $idInfo, string $name){ + parent::__construct($idInfo, $name . " Slab"); $this->slabType = SlabType::BOTTOM(); } public function getId() : int{ - return $this->slabType === SlabType::DOUBLE() ? $this->doubleId : parent::getId(); + return $this->slabType === SlabType::DOUBLE() ? $this->idInfo->getSecondId() : parent::getId(); } protected function writeStateToMeta() : int{ diff --git a/src/pocketmine/block/Snow.php b/src/pocketmine/block/Snow.php index 707a72af2..c33690846 100644 --- a/src/pocketmine/block/Snow.php +++ b/src/pocketmine/block/Snow.php @@ -29,12 +29,6 @@ use pocketmine\item\TieredTool; class Snow extends Solid{ - protected $id = self::SNOW_BLOCK; - - public function __construct(){ - - } - public function getHardness() : float{ return 0.2; } @@ -47,10 +41,6 @@ class Snow extends Solid{ return TieredTool::TIER_WOODEN; } - public function getName() : string{ - return "Snow Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::SNOWBALL, 0, 4) diff --git a/src/pocketmine/block/SnowLayer.php b/src/pocketmine/block/SnowLayer.php index 3244742e1..733ea2595 100644 --- a/src/pocketmine/block/SnowLayer.php +++ b/src/pocketmine/block/SnowLayer.php @@ -39,15 +39,9 @@ use function max; class SnowLayer extends Flowable implements Fallable{ use FallableTrait; - protected $id = self::SNOW_LAYER; - /** @var int */ protected $layers = 1; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->layers - 1; } @@ -60,10 +54,6 @@ class SnowLayer extends Flowable implements Fallable{ return 0b111; } - public function getName() : string{ - return "Snow Layer"; - } - public function canBeReplaced() : bool{ return $this->layers < 8; } diff --git a/src/pocketmine/block/SoulSand.php b/src/pocketmine/block/SoulSand.php index 8dc21f87c..b006f06f1 100644 --- a/src/pocketmine/block/SoulSand.php +++ b/src/pocketmine/block/SoulSand.php @@ -28,16 +28,6 @@ use pocketmine\math\Facing; class SoulSand extends Solid{ - protected $id = self::SOUL_SAND; - - public function __construct(){ - - } - - public function getName() : string{ - return "Soul Sand"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/Sponge.php b/src/pocketmine/block/Sponge.php index d84c352f6..dda5d8e65 100644 --- a/src/pocketmine/block/Sponge.php +++ b/src/pocketmine/block/Sponge.php @@ -26,15 +26,9 @@ namespace pocketmine\block; class Sponge extends Solid{ - protected $id = self::SPONGE; - /** @var bool */ protected $wet = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->wet ? 1 : 0; } @@ -50,8 +44,4 @@ class Sponge extends Solid{ public function getHardness() : float{ return 0.6; } - - public function getName() : string{ - return "Sponge"; - } } diff --git a/src/pocketmine/block/StandingBanner.php b/src/pocketmine/block/StandingBanner.php index 738e5e2c1..fd23d3a74 100644 --- a/src/pocketmine/block/StandingBanner.php +++ b/src/pocketmine/block/StandingBanner.php @@ -35,17 +35,9 @@ use function floor; class StandingBanner extends Transparent{ - protected $id = self::STANDING_BANNER; - - protected $itemId = Item::BANNER; - /** @var int */ protected $rotation = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->rotation; } @@ -58,10 +50,6 @@ class StandingBanner extends Transparent{ return 0b1111; } - protected function getTileClass() : ?string{ - return TileBanner::class; - } - public function getHardness() : float{ return 1; } @@ -70,10 +58,6 @@ class StandingBanner extends Transparent{ return false; } - public function getName() : string{ - return "Standing Banner"; - } - protected function recalculateBoundingBox() : ?AxisAlignedBB{ return null; } diff --git a/src/pocketmine/block/Stem.php b/src/pocketmine/block/Stem.php index e04485944..8201085c4 100644 --- a/src/pocketmine/block/Stem.php +++ b/src/pocketmine/block/Stem.php @@ -25,7 +25,6 @@ namespace pocketmine\block; use pocketmine\event\block\BlockGrowEvent; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\math\Facing; use function array_rand; use function mt_rand; @@ -67,7 +66,7 @@ abstract class Stem extends Crops{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get($this->getItemId(), 0, mt_rand(0, 2)) + $this->getItem()->setCount(mt_rand(0, 2)) ]; } } diff --git a/src/pocketmine/block/StoneBrickStairs.php b/src/pocketmine/block/StoneBrickStairs.php index c0cb53059..bb3ae279b 100644 --- a/src/pocketmine/block/StoneBrickStairs.php +++ b/src/pocketmine/block/StoneBrickStairs.php @@ -27,12 +27,6 @@ use pocketmine\item\TieredTool; class StoneBrickStairs extends Stair{ - protected $id = self::STONE_BRICK_STAIRS; - - public function __construct(){ - - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } @@ -44,8 +38,4 @@ class StoneBrickStairs extends Stair{ public function getHardness() : float{ return 1.5; } - - public function getName() : string{ - return "Stone Brick Stairs"; - } } diff --git a/src/pocketmine/block/StoneButton.php b/src/pocketmine/block/StoneButton.php index 9471b1b78..54d710d75 100644 --- a/src/pocketmine/block/StoneButton.php +++ b/src/pocketmine/block/StoneButton.php @@ -25,12 +25,6 @@ namespace pocketmine\block; class StoneButton extends Button{ - protected $id = self::STONE_BUTTON; - - public function getName() : string{ - return "Stone Button"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/StonePressurePlate.php b/src/pocketmine/block/StonePressurePlate.php index 027d10ae3..501c2ee0f 100644 --- a/src/pocketmine/block/StonePressurePlate.php +++ b/src/pocketmine/block/StonePressurePlate.php @@ -27,15 +27,9 @@ use pocketmine\item\TieredTool; class StonePressurePlate extends Transparent{ - protected $id = self::STONE_PRESSURE_PLATE; - /** @var bool */ protected $powered = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->powered ? 1 : 0; } @@ -48,10 +42,6 @@ class StonePressurePlate extends Transparent{ return 0b1; } - public function getName() : string{ - return "Stone Pressure Plate"; - } - public function isSolid() : bool{ return false; } diff --git a/src/pocketmine/block/Stonecutter.php b/src/pocketmine/block/Stonecutter.php index daaf02d85..36ea45957 100644 --- a/src/pocketmine/block/Stonecutter.php +++ b/src/pocketmine/block/Stonecutter.php @@ -27,16 +27,6 @@ use pocketmine\item\TieredTool; class Stonecutter extends Solid{ - protected $id = self::STONECUTTER; - - public function __construct(){ - - } - - public function getName() : string{ - return "Stonecutter"; - } - public function getToolType() : int{ return BlockToolType::TYPE_PICKAXE; } diff --git a/src/pocketmine/block/Sugarcane.php b/src/pocketmine/block/Sugarcane.php index d9ce7087e..cdde3cbde 100644 --- a/src/pocketmine/block/Sugarcane.php +++ b/src/pocketmine/block/Sugarcane.php @@ -32,17 +32,9 @@ use pocketmine\Player; class Sugarcane extends Flowable{ - protected $id = self::SUGARCANE_BLOCK; - - protected $itemId = Item::SUGARCANE; - /** @var int */ protected $age = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->age; } @@ -55,10 +47,6 @@ class Sugarcane extends Flowable{ return 0b1111; } - public function getName() : string{ - return "Sugarcane"; - } - public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal if($this->getSide(Facing::DOWN)->getId() !== self::SUGARCANE_BLOCK){ diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index 84515ff81..4b71e5b56 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -40,16 +40,6 @@ use const M_PI; class TNT extends Solid{ - protected $id = self::TNT; - - public function __construct(){ - - } - - public function getName() : string{ - return "TNT"; - } - public function getHardness() : float{ return 0; } diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index 85583ac77..4349f7fd2 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -35,8 +35,6 @@ class Trapdoor extends Transparent{ private const MASK_UPPER = 0x04; private const MASK_OPENED = 0x08; - protected $id = self::TRAPDOOR; - /** @var int */ protected $facing = Facing::NORTH; /** @var bool */ @@ -44,10 +42,6 @@ class Trapdoor extends Transparent{ /** @var bool */ protected $top = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return (5 - $this->facing) | ($this->top ? self::MASK_UPPER : 0) | ($this->open ? self::MASK_OPENED : 0); } @@ -64,10 +58,6 @@ class Trapdoor extends Transparent{ return 0b1111; } - public function getName() : string{ - return "Wooden Trapdoor"; - } - public function getHardness() : float{ return 3; } diff --git a/src/pocketmine/block/TrappedChest.php b/src/pocketmine/block/TrappedChest.php index a559c6942..72f8c7a97 100644 --- a/src/pocketmine/block/TrappedChest.php +++ b/src/pocketmine/block/TrappedChest.php @@ -27,9 +27,4 @@ class TrappedChest extends Chest{ //TODO: Redstone! - protected $id = self::TRAPPED_CHEST; - - public function getName() : string{ - return "Trapped Chest"; - } } diff --git a/src/pocketmine/block/Tripwire.php b/src/pocketmine/block/Tripwire.php index 397a5f40d..b55d283b9 100644 --- a/src/pocketmine/block/Tripwire.php +++ b/src/pocketmine/block/Tripwire.php @@ -28,8 +28,6 @@ use pocketmine\item\ItemFactory; class Tripwire extends Flowable{ - protected $id = self::TRIPWIRE; - /** @var bool */ protected $triggered = false; /** @var bool */ @@ -37,10 +35,6 @@ class Tripwire extends Flowable{ /** @var bool */ protected $disarmed = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return ($this->triggered ? 0x01 : 0) | ($this->connected ? 0x04 : 0) | ($this->disarmed ? 0x08 : 0); } @@ -55,10 +49,6 @@ class Tripwire extends Flowable{ return 0b1111; } - public function getName() : string{ - return "Tripwire"; - } - public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::STRING) diff --git a/src/pocketmine/block/TripwireHook.php b/src/pocketmine/block/TripwireHook.php index cf79a4919..84356d34c 100644 --- a/src/pocketmine/block/TripwireHook.php +++ b/src/pocketmine/block/TripwireHook.php @@ -32,8 +32,6 @@ use pocketmine\Player; class TripwireHook extends Flowable{ - protected $id = self::TRIPWIRE_HOOK; - /** @var int */ protected $facing = Facing::NORTH; /** @var bool */ @@ -41,10 +39,6 @@ class TripwireHook extends Flowable{ /** @var bool */ protected $powered = false; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return Bearing::fromFacing($this->facing) | ($this->connected ? 0x04 : 0) | ($this->powered ? 0x08 : 0); } @@ -59,10 +53,6 @@ class TripwireHook extends Flowable{ return 0b1111; } - public function getName() : string{ - return "Tripwire Hook"; - } - public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if(Facing::axis($face) !== Facing::AXIS_Y){ //TODO: check face is valid diff --git a/src/pocketmine/block/UnknownBlock.php b/src/pocketmine/block/UnknownBlock.php index 37ea74af9..53e56d4eb 100644 --- a/src/pocketmine/block/UnknownBlock.php +++ b/src/pocketmine/block/UnknownBlock.php @@ -27,9 +27,8 @@ use pocketmine\item\Item; class UnknownBlock extends Transparent{ - public function __construct(int $id, int $meta = 0){ - $this->id = $id; - $this->variant = $meta; + public function __construct(BlockIdentifier $idInfo){ + parent::__construct($idInfo, "Unknown"); } public function canBePlaced() : bool{ diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index 724726446..a65fc48a8 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -39,15 +39,9 @@ class Vine extends Flowable{ private const FLAG_NORTH = 0x04; private const FLAG_EAST = 0x08; - protected $id = self::VINE; - /** @var bool[] */ protected $faces = []; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return (isset($this->faces[Facing::SOUTH]) ? self::FLAG_SOUTH : 0) | @@ -73,10 +67,6 @@ class Vine extends Flowable{ } } - public function getName() : string{ - return "Vines"; - } - public function getHardness() : float{ return 0.2; } diff --git a/src/pocketmine/block/WallBanner.php b/src/pocketmine/block/WallBanner.php index 41aac1639..5aa2dc757 100644 --- a/src/pocketmine/block/WallBanner.php +++ b/src/pocketmine/block/WallBanner.php @@ -28,8 +28,6 @@ use pocketmine\math\Facing; class WallBanner extends StandingBanner{ - protected $id = self::WALL_BANNER; - /** @var int */ protected $facing = Facing::NORTH; @@ -45,10 +43,6 @@ class WallBanner extends StandingBanner{ return 0b111; } - public function getName() : string{ - return "Wall Banner"; - } - public function onNearbyBlockChange() : void{ if($this->getSide(Facing::opposite($this->facing))->getId() === self::AIR){ $this->getLevel()->useBreakOn($this); diff --git a/src/pocketmine/block/WallSign.php b/src/pocketmine/block/WallSign.php index bca6b6269..b7c7448da 100644 --- a/src/pocketmine/block/WallSign.php +++ b/src/pocketmine/block/WallSign.php @@ -28,8 +28,6 @@ use pocketmine\math\Facing; class WallSign extends SignPost{ - protected $id = self::WALL_SIGN; - /** @var int */ protected $facing = Facing::NORTH; @@ -45,10 +43,6 @@ class WallSign extends SignPost{ return 0b111; } - public function getName() : string{ - return "Wall Sign"; - } - public function onNearbyBlockChange() : void{ if($this->getSide(Facing::opposite($this->facing))->getId() === self::AIR){ $this->getLevel()->useBreakOn($this); diff --git a/src/pocketmine/block/Water.php b/src/pocketmine/block/Water.php index 961adb482..c490df011 100644 --- a/src/pocketmine/block/Water.php +++ b/src/pocketmine/block/Water.php @@ -28,10 +28,6 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; class Water extends Liquid{ - public function __construct(){ - parent::__construct(self::FLOWING_WATER, self::STILL_WATER, "Water"); - } - public function getLightFilter() : int{ return 2; } diff --git a/src/pocketmine/block/WaterLily.php b/src/pocketmine/block/WaterLily.php index 0c4c05ff1..390891225 100644 --- a/src/pocketmine/block/WaterLily.php +++ b/src/pocketmine/block/WaterLily.php @@ -31,16 +31,6 @@ use pocketmine\Player; class WaterLily extends Flowable{ - protected $id = self::WATER_LILY; - - public function __construct(){ - - } - - public function getName() : string{ - return "Lily Pad"; - } - public function getHardness() : float{ return 0.6; } diff --git a/src/pocketmine/block/WeightedPressurePlateHeavy.php b/src/pocketmine/block/WeightedPressurePlateHeavy.php index bcfe010d4..ba72c9000 100644 --- a/src/pocketmine/block/WeightedPressurePlateHeavy.php +++ b/src/pocketmine/block/WeightedPressurePlateHeavy.php @@ -24,10 +24,4 @@ declare(strict_types=1); namespace pocketmine\block; class WeightedPressurePlateHeavy extends WeightedPressurePlateLight{ - - protected $id = self::HEAVY_WEIGHTED_PRESSURE_PLATE; - - public function getName() : string{ - return "Weighted Pressure Plate Heavy"; - } } diff --git a/src/pocketmine/block/WeightedPressurePlateLight.php b/src/pocketmine/block/WeightedPressurePlateLight.php index 7bd0b74e5..9fac934c9 100644 --- a/src/pocketmine/block/WeightedPressurePlateLight.php +++ b/src/pocketmine/block/WeightedPressurePlateLight.php @@ -28,15 +28,9 @@ use pocketmine\item\TieredTool; class WeightedPressurePlateLight extends Transparent{ - protected $id = self::LIGHT_WEIGHTED_PRESSURE_PLATE; - /** @var int */ protected $power = 0; - public function __construct(){ - - } - protected function writeStateToMeta() : int{ return $this->power; } @@ -49,10 +43,6 @@ class WeightedPressurePlateLight extends Transparent{ return 0b1111; } - public function getName() : string{ - return "Weighted Pressure Plate Light"; - } - public function isSolid() : bool{ return false; } diff --git a/src/pocketmine/block/Wheat.php b/src/pocketmine/block/Wheat.php index 8373e960d..59bd52256 100644 --- a/src/pocketmine/block/Wheat.php +++ b/src/pocketmine/block/Wheat.php @@ -29,12 +29,6 @@ use function mt_rand; class Wheat extends Crops{ - protected $id = self::WHEAT_BLOCK; - - public function getName() : string{ - return "Wheat Block"; - } - public function getDropsForCompatibleTool(Item $item) : array{ if($this->age >= 7){ return [ diff --git a/src/pocketmine/block/Wood.php b/src/pocketmine/block/Wood.php index ff970322a..f9dd1c74a 100644 --- a/src/pocketmine/block/Wood.php +++ b/src/pocketmine/block/Wood.php @@ -30,8 +30,8 @@ class Wood extends Solid{ /** @var TreeType */ private $treeType; - public function __construct(int $id, int $variant, TreeType $treeType, ?string $name = null, int $itemId = null){ - parent::__construct($id, $variant, $name, $itemId); + public function __construct(BlockIdentifier $idInfo, string $name, TreeType $treeType){ + parent::__construct($idInfo, $name); $this->treeType = $treeType; } diff --git a/src/pocketmine/block/WoodenButton.php b/src/pocketmine/block/WoodenButton.php index 85f7b978c..d81b4e53b 100644 --- a/src/pocketmine/block/WoodenButton.php +++ b/src/pocketmine/block/WoodenButton.php @@ -25,12 +25,6 @@ namespace pocketmine\block; class WoodenButton extends Button{ - protected $id = self::WOODEN_BUTTON; - - public function getName() : string{ - return "Wooden Button"; - } - public function getHardness() : float{ return 0.5; } diff --git a/src/pocketmine/block/WoodenPressurePlate.php b/src/pocketmine/block/WoodenPressurePlate.php index 8602ff3f2..a01bfaafd 100644 --- a/src/pocketmine/block/WoodenPressurePlate.php +++ b/src/pocketmine/block/WoodenPressurePlate.php @@ -25,12 +25,6 @@ namespace pocketmine\block; class WoodenPressurePlate extends StonePressurePlate{ - protected $id = self::WOODEN_PRESSURE_PLATE; - - public function getName() : string{ - return "Wooden Pressure Plate"; - } - public function getFuelTime() : int{ return 300; } diff --git a/src/pocketmine/block/WoodenSlab.php b/src/pocketmine/block/WoodenSlab.php index 39ae7ac6d..c1a9de02f 100644 --- a/src/pocketmine/block/WoodenSlab.php +++ b/src/pocketmine/block/WoodenSlab.php @@ -25,8 +25,6 @@ namespace pocketmine\block; class WoodenSlab extends Slab{ - protected $id = self::WOODEN_SLAB; - public function getHardness() : float{ return 2; }