Skip to content

andresbytes/NpcDialog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%