Avoid implicit ItemFactory reliance for blocks with special items

this hasn't yet been addressed for signs, since they are a bit of a pain in the ass.
This commit is contained in:
Dylan K. Taylor
2022-06-30 20:00:41 +01:00
parent db2b523762
commit ba079bd9aa
15 changed files with 56 additions and 33 deletions

View File

@ -28,9 +28,9 @@ use pocketmine\block\utils\BannerPatternLayer;
use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\SupportType;
use pocketmine\data\bedrock\DyeColorIdMap;
use pocketmine\item\Banner as ItemBanner;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
@ -129,10 +129,6 @@ abstract class BaseBanner extends Transparent{
}
}
protected function writeStateToItemMeta() : int{
return DyeColorIdMap::getInstance()->toInvertedId($this->color);
}
public function getDropsForCompatibleTool(Item $item) : array{
$drop = $this->asItem();
if($drop instanceof ItemBanner && count($this->patterns) > 0){
@ -149,4 +145,8 @@ abstract class BaseBanner extends Transparent{
}
return $result;
}
public function asItem() : Item{
return VanillaItems::BANNER()->setColor($this->color);
}
}