how do I spawn mobs with dyed armor

Discussion in 'Plugin Development' started by matt11matthew, Jul 2, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    matt11matthew

    Code:
    s.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
                    s.getEquipment().setChestplate(
                            new ItemStack(Material.LEATHER_CHESTPLATE));
                    s.getEquipment().setLeggings(
                            new ItemStack(Material.LEATHER_LEGGINGS));
                    s.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
                    s.getEquipment().setItemInHandDropChance(0.0F);
                    s.getEquipment().setHelmetDropChance(0.0F);
                    s.getEquipment().setChestplateDropChance(0.0F);
                    s.getEquipment().setLeggingsDropChance(0.0F);
                    s.getEquipment().setBootsDropChance(0.0F);
                    s.setCanPickupItems(false);
                    s.setCustomName(ChatColor.DARK_PURPLE + "Enchanted Skeleton");
                    s.setCustomNameVisible(true);
                    s.setMaxHealth(health);
                    s.setHealth(health);

    how do I spawn them with dyed armor
     
  2. Offline

    Larry Newman

  3. Offline

    matt11matthew

    ok I'm new to the fourms
     
  4. @Larry Newman @matt11matthew I can just move the thread. If you find a thread in the wrong section please report and not just tell the user they will probably have a better turnout because the chances are they will double post or make this thread empty. Both of these aren't keeping the forums clean.

    Moved and reverted thread, please report if your thread or someone's is in the wrong place.
     
  5. Offline

    matt11matthew

    yes and how do I rename the tittle?
     
  6. Most material types have a special kind of ItemMeta. An item's item meta holds all kinds of data of the itemstack like display name, lore etc. The class LeatherArmorMeta is a subclass of ItemMeta which has a method setColor(org.bukkit.Color). In case you're new to ItemMeta:
    1. Get the itemstack's meta by calling ItemStack#getItemMeta()
    2. Modify the item meta
    3. To modify the leather armor's color cast from ItemMeta to LeatherArmorMeta
    4. Set the itemstack's meta by calling ItemStack#setItemMeta(ItemMeta)
    5. Done!
     
Thread Status:
Not open for further replies.

Share This Page