Item enchantment glow - 1.4.6?!

Discussion in 'Plugin Development' started by TheTinySpider, Dec 9, 2012.

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

    TheTinySpider

    So how todo this in the new 1.4.6 bukkit?
     
  2. Offline

    fireblast709

    the glow itself is rendered clientside. afaik there is no way to add the glow only
     
  3. Offline

    tommycake50

    you have to add an enchantment i think.
     
  4. Offline

    fireblast709

    he wants the glow, not the enchantment :p
     
  5. Offline

    tommycake50

    ik but since there is no way i know of in which you can only get the glow...
    he could add an unsafe enchantment with level 0. but thats probably not what he is looking for.
    wait he might be able to edit the NBT data for it so it doesnt show the enchantment name.
     
  6. Offline

    fireblast709

    How about registering a custom enchantment, setting its level to -1 and name to ""?
     
    tommycake50 likes this.
  7. Offline

    TheTinySpider

    tommycake50 I tried a lvl 0 enchantment but it just said: ENCHANTMENT.VALUE.0

    fireblast709 How to set an enchantment name?

    TheTinySpider @tommycake50 @fireblast709
    I'm making an custom enchantment plugin using item lores. And lores dont give enchantment glows so thats why i wanted to know it :p Also there is no bukkit class for Nether Stars

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

    tommycake50

    i presume making a class that extends Enchantment.
    and then add all the unimplemented methods.
     
  9. Offline

    TheTinySpider

    @tommycake50 Euhhhhm, thats sounds scary lol. Got an example?
     
  10. Offline

    tommycake50

    just create a new class after the class name add extends Enchantment.
    it will ask yu to add the unimplemented methods so hover over it and click add uniplemented methods.
    and return the appropriate stuff.
     
  11. Offline

    TheTinySpider

    stirante Do you might know how to easly do this? Maybe with nbt tags?
     
  12. Offline

    krazytraynz

    I know for Minecraft client modding you would do this:
    Code:
    public EnumRarity getRarity(ItemStack par1ItemStack)
        {
            return EnumRarity.epic;
        }
    
    ...But I'm that helps here.
     
  13. Offline

    CeramicTitan

    I think you can use packets for this.
     
  14. Offline

    iTidez

  15. Offline

    Woobie

  16. Offline

    stirante

    Unfortunately, only custom potion effects is not working, but I'm working on it.

    I think I know how to add this glow. When ItemStack is rendered in ItemRenderer it checks itemStack.hasEffect(). Then ItemStack in method hasEffect returns method hasEffect(itemStack) from Item class. Class Item returns itemStack.isItemEnchanted() and isItemEnchanted returns if itemStack has tag and if this tag contains compound called ench. So if you put just this tag you won't have any enchantments but glow will stay I think. So it *should* work :D. I'll try to write some code for this.

    EDIT:Here is some code. As always not tested and I hope it will work :)
    Code:
        public static ItemStack addGlow(ItemStack item){
            net.minecraft.server.ItemStack nmsStack = null;
            CraftItemStack craftStack = null;
            if (item instanceof CraftItemStack){
                craftStack = (CraftItemStack)item;
                nmsStack = craftStack.getHandle();
            }
            else {
                craftStack = new CraftItemStack(item);
                nmsStack = craftStack.getHandle();
            }
            NBTTagCompound tag = null;
            if (!nmsStack.hasTag()){
                tag = new NBTTagCompound();
                nmsStack.setTag(tag);
            }
            if (tag == null)
                tag = nmsStack.getTag();
            NBTTagList ench = new NBTTagList();
            tag.set("ench", ench);
            nmsStack.setTag(tag);
            return craftStack;
        }
    EDIT2: It works!!! But minecraft client crashes when you hover on item :/

    EDIT3:It works!!!(Without crashes :D)

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

    TheTinySpider

    stirante Awesome! Thank you very very much!
     
  18. Offline

    monstuhs

    stirante: Do you think you could add this to PrettyScaryLib (if you haven't already)?
     
  19. Offline

    stirante

    Yea, sure :D
    How can I name it?
     
  20. Offline

    monstuhs

    Maybe add a new method to your Namer class (or just an overload to the setName method) to create items with a glow effect and the italicized name (I'm currently using your library to create custom magic items (without vanilla minecraft enchantments))?
     
  21. Offline

    fireblast709

    setGlowing(boolean)?
     
  22. Offline

    stirante

    I already created new class. I called it EnchantemGlow. You can add and remove the glow with it. Btw. for update you can wait a little bit longer, becouse I'm also updating Javadocs :)
     
    monstuhs likes this.
  23. Offline

    monstuhs

    Awesome thanks! Could you perchance overload setName to allow for setting the name in italics?
     
  24. Offline

    fireblast709

    Just add a ChatColor in front of it, an overload is not really needed here ;3
     
    monstuhs likes this.
  25. Offline

    stirante

  26. Offline

    monstuhs

    Oh, didn't realize that. Nice! Thanks!
     
  27. Offline

    TheTinySpider

    stirante Nice thanks :D

    stirante How can i read the lores? For ex. i have a snowball with these lores:
    Magic
    Power Rock

    And i have a event where i wanna read this like:
    If snowball lore contains Power Rock damage dealth +1

    Ive tried this no succes:
    PHP:
    String a;
            
    NBT.getLore(p.getItemInHand()).toString();
         
            if (
    a.contains("Power Rock")) {
                
    damage();
            }
    NBT = your Name Class

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

    stirante

    getLore returns String[] not string.
     
  29. Offline

    TheTinySpider

    How do i read a string out of that? like i wanted?
     
  30. Offline

    stirante

    String[] a = NBT.getLore(p.getItemInHand());
    for (String lore : a) {
    if (a.equalsIgnoreCase("Power Rock")){
    damage();
    break;
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page