Skip to content
master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Jul 23, 2020
Jul 23, 2020

NpcDialog

Download

The compiled phar is available on poggit

How to use

First, you have to register the virion, you can do this during the onEnable() of your plugin main class.

public function onEnable(): void {
    NpcDialog::register($this);
}

Then you have to spawn or get the object of the entity you want to have the dialog form (it can't be a player!). For this example, I will spawn a zombie using PocketMine built-in methods.

$nbt = Entity::createBaseNBT($player, null, $player->yaw, $player->pitch);
$entity = Entity::createEntity("Zombie", $player->level, $nbt);
$entity->spawnToAll();

$entity->setNameTag("Jerry The Zombie!");

Finally you will have to create the form and pair it with the entity.

$form = new DialogForm("This is the dialog text");
 
$form->addButton(new Button("Hi", function(Player $player) {
    $player->sendMessage("Hi!!");
}));

$form->setCloseListener(function(Player $player) {
    $player->sendMessage("You closed the form!");
});

$form->pairWithEntity($entity);

The result of this example would be an entity showing this when it's right-clicked (or hold in the mobile versions):

Example

About

πŸ—½ PocketMine-MP virion to add dialogs to entities easily

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages