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

Set Armor

Discussion in 'Development' started by Jonas, Mar 20, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    How can i set a Armor(Diamond Chestplate) to a player?
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    PHP:
     /*** @var Player $player */
     
    $player->getInventory()->setChestplate(Item::get(Item::DIAMOND_CHESTPLATE01)); 
    EDIT: As of 3.0.0-ALPHA12, PlayerInventory::setChestplate has been removed. ArmorInventory is a new object for Players that contains the same methods PlayerInventory did for armor.
    Simply put, use this instead:
    PHP:
     /*** @var Player $player */
     
    $player->getArmorInventory()->setChestplate(ItemFactory::get(ItemIds::DIAMOND_CHESTPLATE01));
     
    Last edited: Jul 13, 2018
    Taco and jasonwynn10 like this.
  3. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Thanks
     
  4. Taco

    Taco Spider Jockey

    Messages:
    41
    GitHub:
    taconoburrito
  5. Seeker

    Seeker Spider Jockey

    Messages:
    45
    GitHub:
    seeker-devs
    he already replied.. mark this as solved.
     
  6. Taco

    Taco Spider Jockey

    Messages:
    41
    GitHub:
    taconoburrito
    this thread is 3 years old... wtf
     
    GodWeedZao 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.