PrismAPI is a comprehensive utility API for PocketMine-MP that provides a wide range of tools and functionality for server development. It's not just about behavior packs and entity properties – it's a complete toolkit for building powerful Minecraft server plugins.
PrismAPI provides several core utility systems that make plugin development easier and more powerful:
Advanced item management with serialization, runtime ID conversion, and item locking capabilities:
use PrismAPI\item\ItemFactory;
// Get runtime information about items
$legacyInfo = ItemFactory::LEGACY_INFO($item);
$runtimeId = ItemFactory::RUNTIME_ID($item);
$runtimeMeta = ItemFactory::RUNTIME_META($item);
$stringId = ItemFactory::RUNTIME_STRING_ID($item);
// Serialize and deserialize items
$serialized = ItemFactory::SERIALIZE($item);
$deserialized = ItemFactory::DESERIALIZE($serialized);
// Lock items with different modes
$lockedItem = ItemFactory::LOCK($item, ItemLockMode::FULL);
// Get crafting recipes for an item
$crafts = ItemFactory::CRAFTS($item, depth: 3);Comprehensive block management with runtime ID conversion and string ID mapping:
use PrismAPI\block\BlockFactory;
// Create blocks from runtime string IDs
$block = BlockFactory::FROM_RUNTIME_STRING_ID("minecraft:stone");
// Get runtime string IDs from blocks
$stringId = BlockFactory::RUNTIME_STRING_ID_FROM($block);Enhanced command system with automatic overload building and parameter handling:
use PrismAPI\utils\PrismCommand;
class MyCommand extends PrismCommand {
/**
* Builds the command overloads for the command.
*
* @param CommandEnum[] $hardcodedEnums
* @param CommandEnum[] $softEnums
* @param CommandEnumConstraint[] $enumConstraints
* @return array
*/
public function buildOverloads(array &$hardcodedEnums, array &$softEnums, array &$enumConstraints): array
{
return [
new CommandOverload(chaining: false, parameters: [CommandParameter::standard("args", AvailableCommandsPacket::ARG_TYPE_RAWTEXT, 0, true)])
];
}
}Asynchronous programming support with promise-based operations:
use PrismAPI\utils\PromiseResolver;
$promise = new PromiseResolver();
$promise->then(function($result) {
// Handle successful resolution
})->catch(function($error) {
// Handle errors
});
// Resolve or reject the promise
$promise->resolve("Success!");
// or
$promise->reject("Error occurred");PrismAPI implements a full behavior-pack manager so you can use custom behavior packs on your PocketMine-MP server.
- Auto-loading: Behavior packs are automatically detected and loaded from the server’s
behavior_packs/folder. - Script handling: Full support for JavaScript script modules included in behavior packs.
- Smart stacking: Behavior packs are applied in a configurable priority order.
- Encryption keys: Supports encrypted behavior packs with decryption keys.
Create a behavior_packs.yml file inside the behavior_packs/ folder:
behavior_stack:
# Packs are applied from bottom to top
# Higher packs override resources from lower packs
- myBasicPack.zip
- myAdvancedPack.zip
- myCustomPack.zipA behavior pack must include:
- A
manifest.jsondescribing the pack and its modules - Behavior files for entities, blocks, and items
- Optionally, JavaScript script modules
{
"format_version": 2,
"header": {
"name": "My Behavior Pack",
"description": "Description of my pack",
"uuid": "12345678-1234-1234-1234-123456789012",
"version": [1, 0, 0],
"min_engine_version": [1, 20, 0]
},
"modules": [
{
"type": "data",
"uuid": "87654321-4321-4321-4321-210987654321",
"version": [1, 0, 0]
},
{
"type": "script",
"language": "javascript",
"uuid": "11111111-2222-3333-4444-555555555555",
"entry": "scripts/main.js",
"version": [1, 0, 0]
}
]
}The EntityProperties system synchronizes custom properties between server entities and player clients.
- Automatic sync: Properties are synchronized automatically when entities update.
- Type support: Integer and float properties are supported.
- Value validation: Minimum and maximum bounds are enforced.
- Smart caching: Packet caching boosts performance.
use PrismAPI\types\EntitySyncProperties;
// Create an integer property
$healthProperty = new EntitySyncProperties(
"custom_health",
100, // default value
0, // min value
200 // max value
);
// Create a float property
$speedProperty = new EntitySyncProperties(
"movement_speed",
1.0, // default value
0.1, // min value
5.0 // max value
);Each property includes:
- Name: A unique identifier
- Default value: Initial value
- Minimum value: Lower bound
- Maximum value: Upper bound
The system automatically intercepts:
SetActorDataPacketto synchronize propertiesStartGamePacketto set player properties- Entity lifecycle events to clean up removed properties
use PrismAPI\api\BehaviorPackManager;
$manager = BehaviorPackManager::getInstance();
$behaviorPacks = $manager->getBehaviorPacks();use PrismAPI\api\EntityProperties;
$entityProps = EntityProperties::getInstance();
// Use the API methods to manage propertiesThe plugin automatically handles:
- Corrupted or invalid behavior packs
- Manifest parsing errors
- Property synchronization issues
- Cached synchronization packets
- Deferred loading of behavior packs
- Optimized property dispatch
- Memory-aware management
- Efficient item and block ID mapping
- Optimized command overload building
- Smart promise resolution caching
- Download the PrismAPI plugin.
- Place the folder into your server’s
plugins/directory. - Restart the server.
If you have questions or issues:
- Check the API documentation
- Inspect server logs for errors
- Ensure your behavior packs follow the expected format
- PocketMine-MP: API 5.0.0+
- PHP: 8.0+
- Behavior Packs: Format version 2
- Network Protocol: Latest MCPE protocol support
This project is licensed under the GNU General Public License v3.0 – see the LICENSE file for details.