ItemFactory
in package
Uses
SingletonTrait
Manages deserializing item types from their legacy ID/metadata.
This is primarily needed for loading inventories saved in the world (or playerdata storage).
Table of Contents
- $instance : self|null
- $list : array<string|int, Item>
- __construct() : mixed
- air() : Item
- get() : Item
- getAllRegistered() : array<string|int, Item>
- getInstance() : self
- isRegistered() : bool
- Returns whether the specified item ID is already registered in the item factory.
- register() : void
- Maps an item type to its corresponding ID. This is necessary to ensure that the item is correctly loaded when reading data from disk storage.
- remap() : void
- reset() : void
- setInstance() : void
- getListOffset() : int
- itemToBlockId() : int
- make() : self
- registerArmorItems() : void
- registerSpawnEggs() : void
- registerTierToolItems() : void
Properties
$instance
private
static self|null
$instance
= null
$list
private
array<string|int, Item>
$list
= []
Methods
__construct()
public
__construct() : mixed
Return values
mixed —air()
public
static air() : Item
Return values
Item —get()
public
get(int $id[, int $meta = 0 ][, int $count = 1 ][, CompoundTag|null $tags = null ]) : Item
Parameters
- $id : int
- $meta : int = 0
- $count : int = 1
- $tags : CompoundTag|null = null
Tags
Return values
Item —getAllRegistered()
public
getAllRegistered() : array<string|int, Item>
Return values
array<string|int, Item> —getInstance()
public
static getInstance() : self
Return values
self —isRegistered()
Returns whether the specified item ID is already registered in the item factory.
public
isRegistered(int $id[, int $variant = 0 ]) : bool
Parameters
- $id : int
- $variant : int = 0
Return values
bool —register()
Maps an item type to its corresponding ID. This is necessary to ensure that the item is correctly loaded when reading data from disk storage.
public
register(Item $item[, bool $override = false ]) : void
NOTE: If you are registering a new item type, you will need to add it to the creative inventory yourself - it will not automatically appear there.
Parameters
- $item : Item
- $override : bool = false
Tags
Return values
void —remap()
public
remap(ItemIdentifier $identifier, Item $item[, bool $override = false ]) : void
Parameters
- $identifier : ItemIdentifier
- $item : Item
- $override : bool = false
Return values
void —reset()
public
static reset() : void
Return values
void —setInstance()
public
static setInstance(self $instance) : void
Parameters
- $instance : self
Return values
void —getListOffset()
private
static getListOffset(int $id, int $variant) : int
Parameters
- $id : int
- $variant : int
Return values
int —itemToBlockId()
private
static itemToBlockId(int $id) : int
Parameters
- $id : int
Return values
int —make()
private
static make() : self
Return values
self —registerArmorItems()
private
registerArmorItems() : void
Return values
void —registerSpawnEggs()
private
registerSpawnEggs() : void
Return values
void —registerTierToolItems()
private
registerTierToolItems() : void