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

setLore

Discussion in 'Help' started by Mr174, Dec 5, 2019.

  1. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    I've noticed when adding a enchant to an item, if that item has a lore it disappears and the lore can no longer be added now i don't know if i am doing it wrong but is anyone else having this issue?
    PHP:
    $new $this->getExp($i) - $cost;

               
    $p->getInventory()->removeItem($i);

                
    $i->getNamedTag()->setInt('EXP',$new);
                
    $lore = ["§6EXP:§e ".number_format($new)];
                
    $i->setLore($lore);

                
    $i->addEnchantment(new EnchantmentInstance(Enchantment::getEnchantment(Enchantment::EFFICIENCY),1));

                
    $p->getInventory()->addItem($i);
     
    Last edited: Dec 5, 2019
  2. DaRealPandaz

    DaRealPandaz Silverfish

    Messages:
    24
    GitHub:
    mrpandaz
    Try adding the enchantment after setting the lore.
     
  3. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Still nothing lol
     
  4. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Before:
    upload_2019-12-4_18-55-8.png
    After:
    upload_2019-12-4_18-55-38.png
     
  5. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    What DaRealPandaz said to do works. Did you try it?
     
  6. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Yes those are the images
     
  7. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    Show the updated code?
     
  8. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    PHP:
    $p->getInventory()->removeItem($i);

                
    $i->getNamedTag()->setInt('EXP',$new);
                
    $lore = ["§6EXP:§e ".number_format($new)];
                
    $i->setLore($lore);

                
    $i->addEnchantment(new EnchantmentInstance(Enchantment::getEnchantment(Enchantment::EFFICIENCY),1));

                
    $p->getInventory()->addItem($i);
     
  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.