Search by

presentkim / identifier-utils

PresentKim

Library that helps register custom items and entities on axolotl-pm/PocketMine-MP (PocketMine-MP 5 string identifiers)

Package info

github.com/presentkim-pm/identifier-utils

pkg:composer/presentkim/identifier-utils

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

2.0.0 2026-11-27 09:56 UTC

This package is auto-updated.

Last update: 2026-11-27 10:53:02 UTC


README

Packagist CI Stars License


identifier-utils

Register custom items and entities by string identifier on PocketMine-MP 5.

Packagist ยท Changelog ยท Report a bug ยท Request a feature

๐ŸŒŸ Why identifier-utils?

Registering a custom item on PocketMine-MP 5 means touching four separate places. This library does it in one call.

  • StringToItemParser : /give myplugin:ruby and /give ruby work
  • GlobalItemDataHandlers : the item can be saved in worlds / inventories and sent in network item stacks
  • Item type dictionary : the client's item registry gets the item, with its component data
  • Creative inventory : optional

๐Ÿ“ฆ Installation

composer require presentkim/identifier-utils
Requirement Version
Server axolotl-pm/PocketMine-MP (fork of PocketMine-MP 5)
PHP 8.4 or newer

The Poggit virion for the old numeric id system is kept on the legacy/pmmp-5.44 branch (no longer maintained).

๐Ÿš€ Quick start

use kim\present\utils\identifier\IdentifierUtils;
use pocketmine\inventory\CreativeCategory;
use pocketmine\item\Item;
use pocketmine\item\ItemIdentifier;

// In onEnable(), before any player logs in
IdentifierUtils::registerItem(
    "myplugin:ruby",
    static fn(ItemIdentifier $id) : Item => new Item($id, "Ruby"),
    creativeCategory: CreativeCategory::ITEMS,
    aliases: ["red gem"]
);

IdentifierUtils::registerEntity("myplugin:ghost");

The factory receives the ItemIdentifier allocated with ItemTypeIds::newId() and must build the item with it. A custom Item subclass works the same way. Pass components (the components compound of a custom item, with item_properties, minecraft:icon, ...) to describe the item to the client. When omitted a minimal one is generated.

๐Ÿ“– API reference

Method Description
registerItem(string, Closure, ?CompoundTag, ?CreativeCategory, array) : Item Register a custom item everywhere, returns the item
registerEntity(string $stringId) : void Add an entity identifier to the AvailableActorIdentifiersPacket cache
nextItemRuntimeId(?ItemTypeDictionary) : int A network runtime id that is not in the item type dictionary
addToItemTypeDictionary(ItemTypeDictionary, ItemTypeEntry...) : void Add entries to a dictionary
removeNamespace(string $stringId) : string minecraft:diamond => diamond

Notes

  • Call registerItem() and registerEntity() before players log in: the client receives the item registry and the actor identifiers once, while logging in. Already online players do not see later registrations.
  • ItemTypeDictionary is final and has no mutator, while TypeConverter and ItemTranslator share one instance. addToItemTypeDictionary() therefore calls the public constructor of that instance again with the extended entry list. No reflection is used. If the server ever makes those properties readonly, this throws an Error instead of failing silently.

๐Ÿงช Development

composer install --ignore-platform-req='ext-*'
composer test

๐Ÿ“„ License

Distributed under the LGPL-3.0 License. See LICENSE for more information.