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

Give Dyed Leather Armor

Discussion in 'Development' started by Bintang Putra, Jun 8, 2017.

  1. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Hi, i want to give player random dyed leather armor when the players kill mobs

    array = [
    'thepig',
    'milkman'
    ]
    But, i want the dyed leather armor only drops when the mobs has a name included on array
    and how to give color to leather armor?

    is it possible?


    ===EDIT===
    Curent Proggres
    PHP:
    public function pl(Player $pl) : Player
    {
        return 
    $pl;
    }
    public function 
    onkill(EntityDamageByEntityEvent $event)
    {
        
    $entityName $event->getEntity()->getNameTag();
        
    $arr = [
            
    'milkman' => [
                
    'id' => 276,
                
    'damage' => 0,
                
    'count' => 1
            
    ],
            
    'pigman' => [
                
    'id' => 286,
                
    'damage' => 0,
                
    'count' => 1
            
    ]
        ];
        foreach (
    $arr as $r)
        {
            if(isset(
    $arr[$entityName]))
            {
                if(
    $event->getDamager() instanceof Player)
                {
                    
    $player $this->pl($event->getDamager());
                    
    $player->getInventory()->addItem(Item::get($r[$entityName]['id'], $r[$entityName]['id'], $r[$entityName]['id']));
                }
            }
        }
    }
    So How to give the dyed leather armor?
     
    Last edited: Jun 12, 2017
  2. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Yes it is possible, have you made any attempts to try to implement this first?
     
  3. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    of course, i just need to know how to make dyed leather armor
     
  4. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    how to give player dyed armor?
     
  5. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    show some previous attempts of you trying to code this first , and then am sure someone with bother to help.
     
  6. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    PHP:
    public function pl(Player $pl) : Player
    {
        return 
    $pl;
    }
    public function 
    onkill(EntityDamageByEntityEvent $event)
    {
        
    $entityName $event->getEntity()->getNameTag();
        
    $arr = [
            
    'milkman' => [
                
    'id' => 276,
                
    'damage' => 0,
                
    'count' => 1
            
    ],
            
    'pigman' => [
                
    'id' => 286,
                
    'damage' => 0,
                
    'count' => 1
            
    ]
        ];
        foreach (
    $arr as $r)
        {
            if(
    $entityName == $arr)
            {
                if(
    $event->getDamager() instanceof Player)
                {
                    
    $player $this->pl($event->getDamager());
                    
    $player->getInventory()->addItem(Item::get($r[$entityName]['id'], $r[$entityName]['id'], $r[$entityName]['id']));
                }
            }
        }
    }
    i can't get it worked
     
  7. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    i have no idea what your code says tbh , but dyed leather armor is determine using an items damage like spawners. i don't really know sorry if am wrong , its 1:19AM
     
  8. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    i've seen a server that gives dyed leather armor when the player join

    and im curious how to do it
     
  9. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    set compound tag with color to armor
     
    [deleted] likes this.
  10. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    can you make an example? i never used compund tag before
     
  11. Kenn Fatt

    Kenn Fatt Slime

    Messages:
    82
    GitHub:
    kennfatt
    PHP:
    $nbt = new CompoundTag("", []);
    $nbt->customColor = new IntTag("customColor"Color::getColorCode());
    $leatherTierArmor->setCompoundTag($nbt);
    I hope thats work as well :D, btw Color:: it should be as variable, you cant called it there because its not static (i didnt test that code).
     
  12. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Thanks :D
     
  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.