(4.0.0 - 4.21.1) 1.2.0 (4.0.0 - 4.21.1) 1.1.1 (4.0.0 - 4.21.1) 1.1.0 (4.0.0 - 4.21.1) 1.0.7 (4.0.0 - 4.21.1) 1.0.6 (4.0.0 - 4.21.1) 1.0.5 (4.0.0 - 4.21.1) 1.0.4 (4.0.0 - 4.21.1) 1.0.3 (4.0.0 - 4.21.1) 1.0.2 (4.16.0 - 4.21.1) 1.2.1 (4.0.0 - 4.21.1) 1.2.2 (5.0.0 - 5.16.0) 1.3.0 (5.1.3 - 5.16.0) 1.3.2
94
Read more on poggitA PocketMine-MP plugin that implements support for custom blocks, items and entities.
It is important to note that custom blocks will not work properly with other plugins that also modify the runtime block mappings, such as INether and VanillaX.
Name | Contribution |
---|---|
DenielW | Helped research and develop the first versions of Customies |
ScarceityPvP | Helped develop the item components implementation and block-related bug fixes |
JackNoordhuis | Suggested the idea of using async workers and helped write the code which made them function |
Unickorn | Maintained the code during the PM4 betas and kept it up to date |
Registering a custom block can either be done with or without a model using the CustomiesBlockFactory
class. Without a
model all you need to do is register
the block with the same parameters you would use to construct a Block normally.
use twistedasylummc\customies\block\CustomiesBlockFactory;
use pocketmine\block\BlockBreakInfo;
// ...
public function onEnable(): void {
CustomiesBlockFactory::getInstance()->registerBlock(Block::class, "customies:example_block", "Example Block", new BlockBreakInfo(1));
}
// ...
If your block contains a different model, you can provide a Model
as the 4th argument. A model requires an array of
materials, a texture, an origin and a size.
Vector3(0, 0, 0)
is the top right corner of the blockVector3(0, 0, 0)
and Vector3(16, 16, 16)
as the client
does not support blocks being larger than thisuse twistedasylummc\customies\block\CustomiesBlockFactory;
use twistedasylummc\customies\block\Material;
use twistedasylummc\customies\block\Model;
use pocketmine\block\BlockBreakInfo;
use pocketmine\math\Vector3;
// ...
public function onEnable(): void {
$material = new Material(Material::TARGET_ALL, "example", Material::RENDER_METHOD_ALPHA_TEST);
$model = new Model([$material], "geometry.example", new Vector3(-8, 0, -8), new Vector3(16, 16, 16));
CustomiesBlockFactory::getInstance()->registerBlock(Block::class, "customies:example_block", "Example Block", new BlockBreakInfo(1));
}
// ...
$block = CustomiesBlockFactory::getInstance()->get("customies:example_block");
More information about materials and the different properties can be found on docs.microsoft.com.
Registering a custom entity is as simple as registering a normal entity. All you need to do is use
the CustomiesEntityFactory
class to register the entity, and then spawn the entity in the same way as you would
normally.
use twistedasylummc\customies\entity\CustomiesEntityFactory;
// ...
public function onEnable(): void {
CustomiesEntityFactory::getInstance()->registerEntity(ExampleEntity::class, "customies:example_entity");
}
// ...
$entity = new ExampleEntity(new Location(...));
$entity->spawnToAll();
If you want to provide your own creation func,
registerEntity
accepts an optional 3rd parameter to provide your own creation func with the same signature as normal (Closure(World $world, CompoundTag $nbt) : Entity
)
Registering a custom item is as simple as registering a normal item, but the ID is calculated for you. All you need to
do is use the CustomiesItemFactory
class to register the item, and fetch it as you would with a vanilla item.
use twistedasylummc\customies\item\CustomiesItemFactory;
// ...
public function onEnable(): void {
CustomiesItemFactory::getInstance()->registerItem(Item::class, "customies:example_item", "Example Item");
}
// ...
$item = CustomiesItemFactory::getInstance()->get("customies:example_item", 64);
Custom items can also have components which are used to change the behaviour of items client side, such as making it
edible or have durability etc. To get started with components, you need to implement the ItemComponents
interface, use
the ItemComponentsTrait
and call the initComponent
method in the constructor of your class.
use twistedasylummc\customies\item\ItemComponents;
use twistedasylummc\customies\item\ItemComponentsTrait;
use pocketmine\item\Item;
class ExampleItem extends Item implements ItemComponents {
use ItemComponentsTrait;
public function __construct() {
$this->initComponent("example_item", 64);
}
}
Now that you have an item with components, you can add either components or properties using the addComponent
and addProperty
methods.
// ...
$this->addComponent("minecraft:armor", ["protection" => 4]);
$this->addProperty("allow_off_hand", true);
// ...
More information about all the different item components and properties can be found on docs.microsoft.com.