how to dye leather Armour

Discussion in 'Plugin Development' started by StickyMan, Nov 29, 2012.

  1. Offline

    StickyMan

    how to dye leather Armour
    Code (Text):
    1.  ItemStack SonicHelmet = new ItemStack(Material.LEATHER_HELMET);
    thanks
    itai
     
  2. Offline

    StickyMan

    didn't understand how to change the color
    it need to buy easier isn't it
     
  3. StickyMan
    Just paste all under "Changing color of armor:" in a class.
    Then, use this..
    Code (Text):
    1. public static ItemStack setColor(ItemStack item, int colorR, int colorG, int colorB) {
    .. to set a colour.
     
  4. Offline

    StickyMan

    Code (Text):
    1.         if (commandLabel.equalsIgnoreCase("Dye")) {
    2.  
    3.         }
    i want that in that command it will give a dyed lether to the player
     
  5. get the ItemStack you want to colour, and let the player use /Dye red green blue. Then use Integer.parseInt(args[x]) to parse the argument to an integer and use the link Rprrr gave you to color it
     
  6. Offline

    StickyMan

    but i want it will automatic colored
     
  7. then you should have a preset colour somewhere and use that
     
  8. Offline

    StickyMan

    this small fuction become so hard (i mean long code for nothing)
    bukkit need to do less code for it ( :confused: )
     
  9. so what is actually the use of the command dye. If you can specify it a bit more, I might be more of a help :3
     
  10. Offline

    StickyMan

    i am building kits
    and this kit need to be that the helmet, chest-plate and leggings will be collared blue
    and i need to place them on the player
    i know how to place them on the player
    it just the dyed lether
     
  11. Offline

    StickyMan

  12. bump*
     
    devilquak likes this.
  13. Copy only this function:
    Code (Text):
    1.  
    2.     public static ItemStack setArmorColor(ItemStack item, int color) {]
    3.         CraftItemStack craftStack = null;
    4.         net.minecraft.server.ItemStack itemStack = null;
    5.         if (item instanceof CraftItemStack) {
    6.             craftStack = (CraftItemStack) item;
    7.             itemStack = craftStack.getHandle();
    8.         }
    9.         else if (item instanceof ItemStack) {
    10.             craftStack = new CraftItemStack(item);
    11.             itemStack = craftStack.getHandle();
    12.         }
    13.         NBTTagCompound tag = itemStack.tag;
    14.         if (tag == null) {
    15.             tag = new NBTTagCompound();
    16.             tag.setCompound("display", new NBTTagCompound());
    17.             itemStack.tag = tag;
    18.         }
    19.        
    20.         tag = itemStack.tag.getCompound("display");
    21.         tag.setInt("color", color);
    22.         itemStack.tag.setCompound("display", tag);
    23.         return craftStack;
    24.     }
    25.  
    And to color item to blue type:
    helmet = setArmorColor(helmet, 0x0000FF);
     
  14. I bet at some point this will reach the bukkit API, it just needs time. Bukkit coders can't code with the speed of light, you know? If you want things to be done faster go fork bukkit, code it for yourself and do a pull request back to upstream. That's how open source software normally works.

    Also: "so hard"? All you have to do is to copy&paste code and then use ONE, exactly ONE function, so ONE line of code to color the armor. If that's to much I don't know... Even if the API would have it you would have to call ONE function...
     
    Codex Arcanum and stirante like this.

Share This Page