Chameleon Armor

Discussion in 'Plugin Development' started by Splated, Feb 20, 2013.

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

    Splated

    I came up with another strange idea for a mod when I was making this mod http://dev.bukkit.org/server-mods/dyearmor/

    I realized I can make armor any color I want. So I started toying around and made armor that changes color based on the blocks behind the player, and it works!

    but now the problem comes in how do I pick the colors,

    I could list a color for every block type, but custom texture packs will have there own colors.
    any ideas for an easy way?
    [​IMG]
     
    fromgate likes this.
  2. Offline

    Sagacious_Zed Bukkit Docs

    Splated
    The server has no idea what texture pack the client is actually using.
     
  3. Offline

    Splated

    Yeah I know.

    I was thinking some sorta external program that reads the texture file and spits out a yml file the mod can load then it works on servers that uses specific texture packs.

    But all of my lazy ideas sound like more work. :(

    Im thinking a config file that reads a string with a format "block:data->R:B:G" for ever block then players can tweak it by hand if they want. its still a lot of work for a silly mod.
     
  4. Offline

    microgeek

    Can't do it server sided, without typing up a whole bunch of values.
     
  5. Offline

    Splated

    Well i made the armor pick random colors when ever you move if the block is unknown its sorta fun to just watch it all trippy.


    The mod really has no use other then just a fun thing for ops to use. is it worth finishing?
     
  6. Offline

    microgeek

    I'd finish it if I where you, it seems cool.
     
  7. Offline

    shohouku

    It might work if you hook spout ;)

    not sure though.
     
  8. Offline

    ohtwo

    Can you provide the source for this? I'm really interested in how you achieved this.
     
    Wolftic likes this.
  9. Offline

    Splated

    ehh I dont really like spout.
     
  10. Offline

    Deckerz

    just make a random number generator and if it is a certain number set it to a certain color simples :p
     
  11. Offline

    fromgate

  12. Offline

    Splated


    lol what?
     
  13. Offline

    Deckerz

    are you kidding me? *facepalm* :p

    Code:java
    1.  
    2.  
    3. Random rnd = new Random();
    4. int num = rnd.nextInt(insert max number here);
    5. if(num == 1){
    6. //set to a color
    7. }else if(num == 2){
    8. // set to another colour
    9. }
     
  14. Offline

    Splated

    project is started http://dev.bukkit.org/server-mods/chameleon-armor/

    I also found a way to speed up the color picking apparently osx has a built in tool for it.
    [​IMG]



    Not random lol, I mean whats that have to do with spout?

    This is what i use to pick a color when ones not chosen , its in the on player move so it gets real interesting.

    Code:java
    1.  
    2. int red = rand.nextInt(255);
    3. int blue = rand.nextInt(255);
    4. int green = rand.nextInt(255);
    5. Color color = Color.fromBGR(blue, green, red);
    6.  


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  15. Offline

    ZeusAllMighty11

    This would be perfect if people didn't use texture packs D;



    Also, I think there should be a scheduler instead of the move event. Chameleons don't change immediately; it takes a little bit so it seems more realistic that way, plus it's less intensive
     
  16. Offline

    Deckerz

    it doesnt
     
  17. Offline

    Groxlord27

    Just to give you a pat on the back, nice project.
    To answer the questions:
    1.
    There is no way to know the client-side texture pack with this version of bukkit, the least you can do is hope the texture pack adapts it's armor colors as well so it could kinda work. However, even with spout, you would probably never be able to know this. The only way to achieve this would probably for there to be a listener BUILT INTO the minecraft client that feeds data to the server, but that seems complicated. My idea:
    Cross your fingers that the texture pack adapts it's own armor colors.
    It will certainly be an awesome plugin, keep up the good work.
     
  18. Offline

    Splated


    I have such a hard time getting them to accept my silly mods :(

    Yeah the onmove is going to be a problem.
     
  19. Offline

    ZachBora

    Well, you could always make the player appear as falling block entities but that ruins all your work :/

    I would keep the plugin as is, at least for now.
     
  20. Offline

    Splated

    Ok I uploaded the first version I found a way to make the armor self config. Whenever it finds a block not in its list it adds it, and gives it a default color of brown. then players can go edit the color as they like in the config file. I also made the armor shift colors slowly to the new color.


    Now i just need some people who can make a movie!
     
  21. Offline

    ZachBora

    :O I want to try it in conjunction with CloneMe. But I need to make clones wear armor first hmm..
     
  22. Offline

    Rprrr

  23. Offline

    ZachBora

    Splated Dang, I just tried, cloneme and chameleon-armor don't work togheter :(
    The clones armor doesn't get colored. Maybe the IS.clone() didn't copy that special tag you have.

    Splated I made a video http://youtu.be/7MGEnzl1awM

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  24. Offline

    Splated


    Are the clones players? and show up in this.getServer().getOnlinePlayers()?

    Also the top on bottom armor handle different colors.


    Also theres a secret if you type /camoarmor name # the number is the speed the armor changes the default is 10 but its a tad slow I'm still tweeking it but anything above 255 will be instance change.

    ill see if i can get the armor to work on zombies

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  25. Offline

    ZachBora

    They are players but I do not think they show on onlineplayers, it's from the plugin Citizens 2
     
  26. Offline

    Splated

    The problem is here.

    ItemStack hat = livingEntity.getEquipment().getHelmet();
    hat.getItemMeta() == null

    the item seems to lose its ItemMeta

    what are they?

    would they show up in this?

    for(World world: this.getServer().getWorlds())
    for( Player p: world.getPlayers())
    this.updateArmor(p);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  27. Offline

    ZachBora

    I tried with this but it doesn't seem to work.

    Code:java
    1.  
    2. Player powner = Bukkit.getPlayerExact(owner);
    3. Player pclone = (Player) npc.getBukkitEntity();
    4.  
    5. ItemStack is = null;
    6.  
    7. is = powner.getInventory().getBoots().clone();
    8. if(is != null)
    9. {
    10. is.setItemMeta(powner.getInventory().getBoots().getItemMeta().clone());
    11. pclone.getInventory().setBoots(is);
    12. }
    13.  
    14. is = powner.getInventory().getChestplate().clone();
    15. if(is != null)
    16. {
    17. is.setItemMeta(powner.getInventory().getChestplate().getItemMeta().clone());
    18. pclone.getInventory().setChestplate(is);
    19. }
    20.  
    21. is = powner.getInventory().getHelmet().clone();
    22. if(is != null)
    23. {
    24. is.setItemMeta(powner.getInventory().getHelmet().getItemMeta().clone());
    25. pclone.getInventory().setHelmet(is);
    26. }
    27.  
    28. is = powner.getInventory().getLeggings().clone();
    29. if(is != null)
    30. {
    31. is.setItemMeta(powner.getInventory().getLeggings().getItemMeta().clone());
    32. pclone.getInventory().setLeggings(is);
    33. }
    34.  


    They come up in that.

    for(World w: Bukkit.getServer().getWorlds())
    for( Player p: w.getPlayers())
    logger.info("t" + p.getEntityId());

    serverlog :
    23:30:09 [INFO] t25
    23:30:09 [INFO] t233288
    23:30:09 [INFO] t235217

    Edit: I tried the same with getOnlinePlayers and only 25 showed up, so if you use world.getPlayers it could work I suppose.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  28. Offline

    Splated

    ok i put up a v.2 that uses the world player loop try that also its faster and works with gold and iron and some other blocks :)
     
  29. Offline

    ZachBora

    Ok I'll try it tomorrow, it's getting late here.

    Edit: Too bad leather armor doesn't hide the whole body :p
     
  30. Offline

    Chlorek

    However, even with texturepacks colors stay rather the same. Dirt is still brown, stone is still gray, nothing changes. Sometime it is a bit different, but basicaly it is the same. If you want to check colors in the current texture pack, you can simply make mod, it can be optional (I prefere using Forge). However there is other problem, because cameleon will be then other for every user. For example dirt block is black for me (person who wears), but if someone else see me and he has dirt block in green color he will see black armor. This way plugin is going to be really weird. The best thing you can do is making it for default texturepack.
     
Thread Status:
Not open for further replies.

Share This Page