mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Added SkullType enum, some cleanup to skull handling
this is still more ugly than I'd like it to be because of the way the blockfactory currently works.
This commit is contained in:
@ -26,10 +26,10 @@ namespace pocketmine\item;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\tile\Skull;
|
||||
use function constant;
|
||||
use function defined;
|
||||
use function explode;
|
||||
@ -172,12 +172,6 @@ class ItemFactory{
|
||||
self::register(new ItemBlock(Block::NETHER_WART_PLANT, 0, Item::NETHER_WART));
|
||||
self::register(new ItemBlock(Block::OAK_DOOR_BLOCK, 0, Item::OAK_DOOR));
|
||||
self::register(new ItemBlock(Block::REPEATER_BLOCK, 0, Item::REPEATER));
|
||||
self::register(new ItemBlock(Block::SKULL_BLOCK, Skull::TYPE_CREEPER, Item::SKULL));
|
||||
self::register(new ItemBlock(Block::SKULL_BLOCK, Skull::TYPE_DRAGON, Item::SKULL));
|
||||
self::register(new ItemBlock(Block::SKULL_BLOCK, Skull::TYPE_HUMAN, Item::SKULL));
|
||||
self::register(new ItemBlock(Block::SKULL_BLOCK, Skull::TYPE_SKELETON, Item::SKULL));
|
||||
self::register(new ItemBlock(Block::SKULL_BLOCK, Skull::TYPE_WITHER, Item::SKULL));
|
||||
self::register(new ItemBlock(Block::SKULL_BLOCK, Skull::TYPE_ZOMBIE, Item::SKULL));
|
||||
self::register(new ItemBlock(Block::SPRUCE_DOOR_BLOCK, 0, Item::SPRUCE_DOOR));
|
||||
self::register(new ItemBlock(Block::SUGARCANE_BLOCK, 0, Item::SUGARCANE));
|
||||
self::register(new LeatherBoots());
|
||||
@ -236,6 +230,10 @@ class ItemFactory{
|
||||
self::register(new WritableBook());
|
||||
self::register(new WrittenBook());
|
||||
|
||||
foreach(SkullType::getAll() as $skullType){
|
||||
self::register(new Skull(Item::SKULL, $skullType->getMagicNumber(), $skullType->getDisplayName(), $skullType));
|
||||
}
|
||||
|
||||
/** @var int[]|\SplObjectStorage $dyeMap */
|
||||
$dyeMap = new \SplObjectStorage();
|
||||
$dyeMap[DyeColor::BLACK()] = 16;
|
||||
|
47
src/pocketmine/item/Skull.php
Normal file
47
src/pocketmine/item/Skull.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
|
||||
class Skull extends Item{
|
||||
|
||||
/** @var SkullType */
|
||||
private $skullType;
|
||||
|
||||
public function __construct(int $id, int $variant, string $name, SkullType $skullType){
|
||||
parent::__construct($id, $variant, $name);
|
||||
$this->skullType = $skullType;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return BlockFactory::get(Block::SKULL_BLOCK);
|
||||
}
|
||||
|
||||
public function getSkullType() : SkullType{
|
||||
return $this->skullType;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user