mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 21:24:53 +00:00
TypeConverter: use SingletonTrait
This commit is contained in:
parent
9cf410d484
commit
dbd51610c3
@ -39,29 +39,14 @@ use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\NetworkInventoryAction;
|
||||
use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
|
||||
class TypeConverter{
|
||||
use SingletonTrait;
|
||||
|
||||
private const DAMAGE_TAG = "Damage"; //TAG_Int
|
||||
private const DAMAGE_TAG_CONFLICT_RESOLUTION = "___Damage_ProtocolCollisionResolution___";
|
||||
|
||||
/** @var self|null */
|
||||
private static $instance;
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public static function getInstance() : self{
|
||||
if(self::$instance === null){
|
||||
self::$instance = new self;
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function setInstance(self $instance) : void{
|
||||
self::$instance = $instance;
|
||||
}
|
||||
|
||||
public function coreItemStackToRecipeIngredient(Item $itemStack) : RecipeIngredient{
|
||||
$meta = $itemStack->getMeta();
|
||||
return new RecipeIngredient($itemStack->getId(), $meta === -1 ? 0x7fff : $meta, $itemStack->getCount());
|
||||
|
Loading…
x
Reference in New Issue
Block a user