Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Path

Image Path is a library that provides the path to item's image using AI.

Usage

Install await-generator in the src of your plugin

Register ImagePath

use ImagePath\ImagePath;

if(!ImagePath::isRegistered())
{
    ImagePath::register($this);
}

Add item_texture.json & terrain_texture.json in the resources of your plugin to add custom items, simply add them to these files

Don't forget to save these files

$this->saveResource("item_textures.json");
$this->saveResource("terrain_textures.json");

How to use ?

To obtain the paths to item images:

use ImagePath\ImagePath;
use SOFe\AwaitGenerator\Await;

Await::f2c(function () use ($sender, $form){
    try {
        $response = yield ImagePath::getInstance()->askGemini([$sender->getInventory()->getItemInHand()]); // array of items
        $paths = ImagePath::getInstance()->getImagePath($response);

        var_dump($paths[ImagePath::getInstance()->formatItemName($sender->getInventory()->getItemInHand())]); // return the path of your item's image e.g. textures/items/diamond_sword
    } catch (Exception $e) 
    {
        var_dump($e->getMessage());
    }
});

There is a delay of 2-3 seconds, so I advise you to save each time you retrieve the paths of the item images and then next time delete from the request those already retrieved like that:

$allPaths = [];

array_merge($paths, $allPaths) // save paths

array_diff_key($arrayToCheckWithItemName, $allPaths) // remove paths already saved

About

a Pocketmine-MP API to get the path to item's image using AI.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages