Skip to content

LootItemConverter 5.46.0 ​

final class · pocketmine\loot\LootItemConverter · source

Converts loot stacks (Java item ids and components) to PocketMine items, using GeyserMC's Java -> Bedrock item mappings from the vanilla data cache. Stacks of items PocketMine does not have are dropped (null).

Methods ​

bedrockItem() ​

php
public static function bedrockItem(string $javaId) : array

Bedrock item id and meta of a Java item.

bedrockToItem() ​

php
public static function bedrockToItem(string $bedrockId, int $meta) : ?\pocketmine\item\Item

A PocketMine item from a Bedrock item id and meta, or null if PocketMine has no such item.

Ordinary items are deserialized directly. Block items cannot be: on disk and on the network they carry their block state, which the mappings do not have (and GeyserMC's meta of a block item is its legacy one). Those are looked up in a table of the item ids PocketMine serializes its own blocks and items to.

enchantment() ​

php
public static function enchantment(string $javaId) : ?\pocketmine\item\enchantment\Enchantment

The PocketMine enchantment of a Java enchantment id, or null if PocketMine does not have it.

enchantmentLevel() ​

php
public static function enchantmentLevel(\pocketmine\item\Item $item, string $javaEnchantmentId) : int

Level of a Java enchantment on a PocketMine item.

fromItem() ​

php
public static function fromItem(\pocketmine\item\Item $item) : \pocketmine\loot\LootStack

A PocketMine item as a loot stack (Java id and enchantments), e.g. the tool of a loot context.

potionType() ​

php
public static function potionType(string $javaPotion) : ?\pocketmine\item\PotionType

toItem() ​

php
public static function toItem(\pocketmine\loot\LootStack $stack) : ?\pocketmine\item\Item

Converts a loot stack to a PocketMine item, or returns null if PocketMine has no such item (or the stack is empty).

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.