1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Apply texture to custom registered item?

Discussion in 'Development' started by Atomization, Jan 25, 2022.

  1. Atomization

    Atomization Baby Zombie

    Messages:
    120
    GitHub:
    iAtomPlaza
    I've been trying to apply a texture to a custom item which I have registered. I don't want to use an existing plugin and only am trying to achieve this with minimum amount of code because I'm writing for a core.

    here are the resources I've been looking at:
    https://github.com/Big-Potatoes/Cus...Refaltor/Natof/CustomItem/CustomItem.php#L253
    https://github.com/alvin0319/Custom...item/properties/CustomItemProperties.php#L170

    And here is when I've tried so far:
    PHP:
    <?php
    use pocketmine\item\ItemFactory;
    use 
    pocketmine\nbt\tag\CompoundTag;

    // ItemManager.php
    public function __construct(public Main $plugin) {
       
    $this->registerItem(new CannonSpawnEgg"textures/items/egg_cannon");
    }

    public function 
    registerItem(Item $itemstring $texture): void {
       
    $nbt CompoundTag::create()
           ->
    setTag("components"CompoundTag::create()
               ->
    setTag("minecraft:icon"CompoundTag::create()
                   ->
    setString("texture"$texture)));

       
    $item->setNamedTag($nbt);
       
    ItemFactory::getInstance()->register($itemtrue);
    }
    I already have a texture pack loaded that has the images I want to use, there are no errors, and when I give myself the item, it has the default 'missing_texture' image.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.