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

FormAPI path images not working?

Discussion in 'Development' started by Levi, Apr 20, 2019.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    When I use link for button images, it takes forever to load unless i switch window and back to minecraft.
    I tried image path type but its giving black and purple image

    PHP:
    $form->addButton("Apple",0,$this->getPlugin()->getDataFolder()."images/apple.png");
    and yes.. theres an apple.png in images in my plugin's folder
     
  2. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
    As far as I know, image path just can be used through a texture pack in your server.

    For example, if do you want to use the apple image, your code have to see like this (supposing that you are using the default texture pack):
    PHP:
    $form->addButton("Apple"0"textures/items/apple");
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Where's the texture folder?
     
  4. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
  6. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    I added it to resource packs folder. When I var dump resource stacks, it gives zero.
    PHP:
            var_dump(Server::getInstance()->getResourcePackManager()->getResourceStack());
    PHP:
    #This configuration file controls global resources used on your PocketMine-MP server.

    #Choose whether players must use your chosen resource packs to join the server.
    #NOTE: This will do nothing if there are no resource packs in the stack below.
    force_resourcestrue
    resource_stack
    :
     
    #Resource packs here are applied from bottom to top. This means that resources in higher packs will override those in lower packs.
     #Entries here must indicate the filename of the resource pack.
     #Example
        
    vanilla.zip
     
    # - vanilla.zip
     #If you want to force clients to use vanilla resources, you must place a vanilla resource pack in your resources folder and add it to the stack here.
     
  7. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
    You don't need to put it. PocketMine already use the default resource pack of MCBE. Just use it as a reference for the path.
     
  8. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    How do i exactly go to textures/items/apple.png?
     
  9. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
    Download and extract that.
    Then, you'll have a folder named "textures". Inside the folder, you'll see all the textures. If do you want to go to the apple texture, just go to the "items" folder.
     
  10. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    That's what I did bro, but it's just giving me the block and purple image whatever.
     
  11. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
    May I see your code please?
     
  12. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    PHP:
    $form->addButton("Button",0,$this->getDataFolder()."textures\items\apple.png);
     
  13. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
    Remove "$this->getDataFolder() ." and the ".png" after "apple"
    Your code should look like this
    PHP:
    $form->addButton("Button"0"textures/items/apple");
     
  14. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Ok.. then where do i put the textures folder
     
  15. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
     
  16. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Ahhh..... thanks bro

    But how is this any different than a folder with pics in my plugin folder?
     
  17. DrakerZR

    DrakerZR Silverfish

    Messages:
    21
    GitHub:
    drakerzr
    I see it like this.
    If do you use your plugin folder ($this->getDataFolder()) you are using this path:
    "Texture Pack/Your plugin folder/textures/items/apple" (this path doesn't exists in your textures, that's why appears the black and purple imagen)

    Instead, without your plugin folder, you are using this path:
    "Texture Pack/textures/items/apple"
     
  18. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    The "path" attribute is sent to the client directly. The client cannot access anything in your server's data folder.
     
    HimbeersaftLP likes this.
  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.