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

Item naming

Discussion in 'Development' started by Teamblocket, Mar 5, 2017.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    How would I go about not changing an items custom name, but adding a new line to it with \n. Keep in mind, i dont want to change the original line, just add to it.
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I think you could use something like this:
    PHP:
     /*** @var Item $item ***/
     
    $item->setCustomName($item->getName()\/*"Your Text Here"*/); 
     
  3. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    PHP:
    $item->setCustomName($item->getName()."\n"."New Name");
     
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    it tells me to define $item do i do $item = Item::get(279, 0, 1);
     
  5. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    That should work.
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Yes
    $item should be an instance of the Item class
    PHP:
    $item Item::get(279,0,1);
    $item->setCustomName($item->getName()."\n"."New Name");
     
  7. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    Ok I added the code but I want it to be the item the player is holding not a diamond sword
     
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    This is the development section, you should know how to do it on your own before asking others to just give you code.
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    PHP:
     /*** @var Player $player ***/
    $item $player->getInventory()->getItemInHand();
     
    TheDiamondYT 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.