From e8fe3d066443ab60c344e6e67ad19d5103daace5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Jul 2019 18:30:02 +0100 Subject: [PATCH] Replace some ItemFactory blockitem fetches with VanillaBlocks::THING()->asItem() --- src/pocketmine/block/BlockFactory.php | 15 +++++++-------- src/pocketmine/block/EnderChest.php | 3 +-- src/pocketmine/block/Farmland.php | 5 ++--- src/pocketmine/block/Grass.php | 3 +-- src/pocketmine/block/GrassPath.php | 3 +-- src/pocketmine/block/Mycelium.php | 3 +-- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 9fa8ebd31..c757bad17 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -49,7 +49,6 @@ use pocketmine\block\utils\InvalidBlockStateException; use pocketmine\block\utils\PillarRotationTrait; use pocketmine\block\utils\TreeType; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\item\ItemIds; use pocketmine\item\TieredTool; use pocketmine\world\Position; @@ -185,32 +184,32 @@ class BlockFactory{ self::register(new Ice(new BID(Ids::ICE), "Ice")); self::register(new class(new BID(Ids::MONSTER_EGG, Meta::INFESTED_STONE), "Infested Stone") extends InfestedStone{ public function getSilkTouchDrops(Item $item) : array{ - return [ItemFactory::get(ItemIds::STONE)]; + return [VanillaBlocks::STONE()->asItem()]; } }); self::register(new class(new BID(Ids::MONSTER_EGG, Meta::INFESTED_COBBLESTONE), "Infested Cobblestone") extends InfestedStone{ public function getSilkTouchDrops(Item $item) : array{ - return [ItemFactory::get(ItemIds::COBBLESTONE)]; + return [VanillaBlocks::COBBLESTONE()->asItem()]; } }); self::register(new class(new BID(Ids::MONSTER_EGG, Meta::INFESTED_STONE_BRICK), "Infested Stone Brick") extends InfestedStone{ public function getSilkTouchDrops(Item $item) : array{ - return [ItemFactory::get(ItemIds::STONE_BRICK)]; + return [VanillaBlocks::STONE_BRICKS()->asItem()]; } }); self::register(new class(new BID(Ids::MONSTER_EGG, Meta::INFESTED_STONE_BRICK_MOSSY), "Infested Mossy Stone Brick") extends InfestedStone{ public function getSilkTouchDrops(Item $item) : array{ - return [ItemFactory::get(ItemIds::STONE_BRICK, Meta::STONE_BRICK_MOSSY)]; + return [VanillaBlocks::MOSSY_STONE_BRICKS()->asItem()]; } }); self::register(new class(new BID(Ids::MONSTER_EGG, Meta::INFESTED_STONE_BRICK_CRACKED), "Infested Cracked Stone Brick") extends InfestedStone{ public function getSilkTouchDrops(Item $item) : array{ - return [ItemFactory::get(ItemIds::STONE_BRICK, Meta::STONE_BRICK_CRACKED)]; + return [VanillaBlocks::CRACKED_STONE_BRICKS()->asItem()]; } }); self::register(new class(new BID(Ids::MONSTER_EGG, Meta::INFESTED_STONE_BRICK_CHISELED), "Infested Chiseled Stone Brick") extends InfestedStone{ public function getSilkTouchDrops(Item $item) : array{ - return [ItemFactory::get(ItemIds::STONE_BRICK, Meta::STONE_BRICK_CHISELED)]; + return [VanillaBlocks::CHISELED_STONE_BRICKS()->asItem()]; } }); @@ -318,7 +317,7 @@ class BlockFactory{ $stoneBreakInfo = new BlockBreakInfo(1.5, BlockToolType::PICKAXE, TieredTool::TIER_WOODEN, 30.0); self::register(new class(new BID(Ids::STONE, Meta::STONE_NORMAL), "Stone", $stoneBreakInfo) extends Solid{ public function getDropsForCompatibleTool(Item $item) : array{ - return [ItemFactory::get(Item::COBBLESTONE)]; + return [VanillaBlocks::COBBLESTONE()->asItem()]; } }); self::register(new Stair(new BID(Ids::NORMAL_STONE_STAIRS), "Stone Stairs", $stoneBreakInfo)); diff --git a/src/pocketmine/block/EnderChest.php b/src/pocketmine/block/EnderChest.php index 4902b46f4..e68c11ef4 100644 --- a/src/pocketmine/block/EnderChest.php +++ b/src/pocketmine/block/EnderChest.php @@ -26,7 +26,6 @@ namespace pocketmine\block; use pocketmine\block\tile\EnderChest as TileEnderChest; use pocketmine\block\utils\BlockDataValidator; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\item\TieredTool; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; @@ -85,7 +84,7 @@ class EnderChest extends Transparent{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get(Item::OBSIDIAN, 0, 8) + VanillaBlocks::OBSIDIAN()->asItem()->setCount(8) ]; } } diff --git a/src/pocketmine/block/Farmland.php b/src/pocketmine/block/Farmland.php index 2dfc1f8ab..67dafa0ef 100644 --- a/src/pocketmine/block/Farmland.php +++ b/src/pocketmine/block/Farmland.php @@ -25,7 +25,6 @@ namespace pocketmine\block; use pocketmine\block\utils\BlockDataValidator; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; @@ -97,7 +96,7 @@ class Farmland extends Transparent{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get(Item::DIRT) + VanillaBlocks::DIRT()->asItem() ]; } @@ -106,6 +105,6 @@ class Farmland extends Transparent{ } public function getPickedItem(bool $addUserData = false) : Item{ - return ItemFactory::get(Item::DIRT); + return VanillaBlocks::DIRT()->asItem(); } } diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index fe852a012..25b9188e4 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -27,7 +27,6 @@ use pocketmine\event\block\BlockSpreadEvent; use pocketmine\item\Fertilizer; use pocketmine\item\Hoe; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\item\Shovel; use pocketmine\math\Facing; use pocketmine\math\Vector3; @@ -44,7 +43,7 @@ class Grass extends Solid{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get(Item::DIRT) + VanillaBlocks::DIRT()->asItem() ]; } diff --git a/src/pocketmine/block/GrassPath.php b/src/pocketmine/block/GrassPath.php index e6e003429..4861cc1f6 100644 --- a/src/pocketmine/block/GrassPath.php +++ b/src/pocketmine/block/GrassPath.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace pocketmine\block; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; @@ -46,7 +45,7 @@ class GrassPath extends Transparent{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get(Item::DIRT) + VanillaBlocks::DIRT()->asItem() ]; } } diff --git a/src/pocketmine/block/Mycelium.php b/src/pocketmine/block/Mycelium.php index 1fb34909e..fa1a4e12e 100644 --- a/src/pocketmine/block/Mycelium.php +++ b/src/pocketmine/block/Mycelium.php @@ -25,7 +25,6 @@ namespace pocketmine\block; use pocketmine\event\block\BlockSpreadEvent; use pocketmine\item\Item; -use pocketmine\item\ItemFactory; use pocketmine\math\Facing; use function mt_rand; @@ -37,7 +36,7 @@ class Mycelium extends Solid{ public function getDropsForCompatibleTool(Item $item) : array{ return [ - ItemFactory::get(Item::DIRT) + VanillaBlocks::DIRT()->asItem() ]; }