1. Go to this page and download the library: Download cosmicpe/npcdialogue library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cosmicpe / npcdialogue example snippets
use cosmicpe\npcdialogue\dialogue\texture\DefaultNpcDialogueTexture;
use cosmicpe\npcdialogue\NpcDialogueBuilder;
use cosmicpe\npcdialogue\NpcDialogueManager;
use pocketmine\player\Player;
$dialogue = NpcDialogueBuilder::create()
->setName("Dialogue Name")
->setText("This is an example dialogue.")
->setDefaultNpcTexture(DefaultNpcDialogueTexture::TEXTURE_NPC_10)
->addSimpleButton("Okay")
->addSimpleButton("Whatever", function(Player $player) : void{
$player->sendMessage("You clicked 'Whatever' button");
})
->setCloseListener(function(Player $player) : void{
$player->sendMessage("You closed the dialogue");
})
->build();
NpcDialogueManager::send($player, $dialogue);
use cosmicpe\npcdialogue\NpcDialogueBuilder;
use cosmicpe\npcdialogue\NpcDialogueManager;
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
NpcDialogueManager::send($player, NpcDialogueBuilder::create()
->setName("Honey Bee")
->setText(file_get_contents("bee_movie_script.txt"))
->setEntityNpcTexture(EntityIds::BEE)
->build());
use cosmicpe\npcdialogue\NpcDialogueBuilder;
use cosmicpe\npcdialogue\NpcDialogueManager;
NpcDialogueManager::send($player, NpcDialogueBuilder::create()
->setName("This is YOU!")
->setText("You have the power within you to overcome any obstacle that comes your way. You are resilient, capable, and determined to achieve greatness. Embrace the challenges, believe in yourself, and remember that every step you take brings you closer to your dreams. Keep pushing forward with unwavering determination, for the world awaits the extraordinary impact you're destined to make.")
->setSkinNpcTexture($player->getSkin())
->build());
use cosmicpe\npcdialogue\NpcDialogueBuilder;
use cosmicpe\npcdialogue\NpcDialogueManager;
$parent = NpcDialogueTextureOffset::defaultPlayerPortrait();
$portrait_offset = new NpcDialogueTextureOffset(2.0, 2.0, 2.0, $parent->translate_x, $parent->translate_y, $parent->translate_z);
NpcDialogueManager::send($player, NpcDialogueBuilder::create()
->setName("This is YOU!")
->setText("You have the power within you to overcome any obstacle that comes your way. You are resilient, capable, and determined to achieve greatness. Embrace the challenges, believe in yourself, and remember that every step you take brings you closer to your dreams. Keep pushing forward with unwavering determination, for the world awaits the extraordinary impact you're destined to make.")
->setSkinNpcTexture($player->getSkin(), null, $portrait_offset)
->build());