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

Solved Get item data

Discussion in 'Development' started by RoyalMCPE, Jun 2, 2017.

  1. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    What would be the best way to transfer a item name, damage, lore, etc.. to another item without doing $item2->setCustomName("Name"); etc...
     
  2. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    What do you mean? You can use getName from item one as '$name' and use setCustomName($name)
     
  3. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    Yes, but then I would have to do that with enchantments, and the lore. It would just make the code look messy
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Are the two items exact copies? You could clone the Item object in that case. You could also get the nbt from one item and set it to the other. I think $item2->setNamedTag($item1->getNamedTag()) would work. That should work for lore, custom name, enchantments, and other nbt tags. Damage would be different.
     
    jasonwynn10 and Zuruki like this.
  5. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    Thank you
     
  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.