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

Setting name for a new item overrided

Discussion in 'Development' started by iCirgio, Jul 16, 2018.

  1. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    Ok so I made a new item extending Item. It is registered but when I do /give the item doesn't show in inventory but command goes through. Also when the item is in my inventory it becomes bugged and start shifting iterms in my inventory
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Can we see the code?
     
  3. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    powergem.php
    PHP:
    class powergem extends Item {
           public function 
    __construct($meta 0){
                      
    parent::__construct(560$meta"Power Gem");
        }
           public function 
    getCustomName() : String {
                   return 
    "Power Gem";
        }
           public function 
    getMaxStackSize() : int {
                   return 
    16;
        }
    loader.php to register item
    PHP:
    ItemFactory::registerItem(new powergem(), true);
     
  4. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    The item id has too be a item that is currently in mcbe, the id 560 doesn't exists in the games ids or even pmmps
     
  5. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I think there's a misunderstanding in what it means to construct an Item in PMMP. You can only create items that can be handled by the client, so you can't create items that don't exist in the game. You can, however, create your own Item class that contains different properties from the default in PMMP, or implement Items that are in MCBE but not in PMMP yet.
     
  6. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    oh okay so i can like for example make it extend Kelp instead of Item and retexture it?
     
  7. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    How do i override the name? I'm getting an error where it crashes saying I can't override getName()?
     
  8. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
  9. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    i did but it doesnt set the name of the new item
    i get an error saying cannot override final method pocketmine\item\Item::getName()
     
    Last edited: Jul 18, 2018
  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.