Solved How to remove these "descriptions" from items?

Discussion in 'Plugin Development' started by Quaro, Oct 28, 2013.

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

    Quaro

    How to remove these "descriptions" from items?

    [​IMG]
     
  2. Offline

    NathanWolf

    I don't think that text is part of the lore, I think it's automatically displayed for enchanted items- so I'm not sure that you can get rid of it while retaining the enchantments. (I could be wrong)
     
  3. Offline

    Garris0n

  4. Offline

    JoTyler

    It has something to do with the lure. Set the lure to null. get the item like this.

    Something like this:
    Code:
    Itemstack item....()....
    Itemmeta imeta = item.getmeta();
    String lure = "";
    imeta.setdesc(1, lure);
     
  5. Offline

    Quaro

    JoTyler Im sure that will not work.
     
  6. Offline

    NathanWolf

    I think JoTyler was talking about the lore, which you could try- but I don't think that text is part of the lore, as I mentioned.

    I've had items where I added enchantments and set my own lore, the lore I set shows up as well as the standard enchantment text.
     
  7. Offline

    Garris0n

    For the enchanted book, you might be able to actually remove the enchantment from it, although then it won't have the enchantment to apply anymore. For the others, you may be able to edit the item attributes to remove it, but I'm not sure. Bukkit hasn't released any API for attributes but there are a couple in the resources section.
     
  8. Offline

    Quaro

    Garris0n Examples, Links - would be great.
     
  9. Offline

    Garris0n

    For the enchanted book, I'm not sure if it will work, but try doing removeEnchantment(the enchantment) on the ItemStack. For the attributes, I don't think it will work, but here.
     
  10. Offline

    Quaro

    Garris0n Sorry, i don't know how to use it. Removing that from weapons atleast, would be great :( But i need example. I'm not verry good in english.
     
  11. Offline

    Garris0n

    I don't know how to use it either, but you could try reading the code examples. Perhaps somebody here could explain it to you in whatever your primary language is?
     
  12. Offline

    Quaro

  13. Offline

    JoTyler

    Micius Ok then, do you have a better idea ?
     
  14. Offline

    Quaro

  15. Offline

    NathanWolf

    I'm honestly not sure this is possible. I think the client renders that text based on the enchantment data of the item.

    Unless someone says otherwise, if you want enchanted items you have to have their enchantment descriptions.

    What exactly are you trying to do? You can have the enchantment glow without enchantments, if that's what you're after.
     
  16. Offline

    Goblom

    You can remove the enchantment names via protocol lib but the "+6 Attack Damage" Im not entirely sure about that. Does that show when you are not in creative ?
     
    NathanWolf likes this.
  17. Offline

    Quaro

    NathanWolf Im trying to make new item system, there will be no default enchant system, no default items, or crafting recipes, so i just want to remove it from my custom items(or remove it for all).
     
  18. Offline

    amhokies

    Code:java
    1. private static ItemStack removeAttributes(ItemStack item)
    2. {
    3. net.minecraft.server.v1_6_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
    4. NBTTagCompound tag;
    5. if (!nmsStack.hasTag())
    6. {
    7. tag = new NBTTagCompound();
    8. nmsStack.setTag(tag);
    9. }
    10. else
    11. {
    12. tag = nmsStack.getTag();
    13. }
    14. NBTTagList am = new NBTTagList();
    15. tag.set("AttributeModifiers", am);
    16. nmsStack.setTag(tag);
    17. return CraftItemStack.asCraftMirror(nmsStack);
    18. }
     
  19. Offline

    Comphenix

    This approach is unfortunately very unreliable, as Bukkit will attempt to this hack whenever it gets a chance. Which occurs almost immediately in creative mode, and occasionally in survival mode when doing basic inventory management.

    Your best bet is probably to do something akin to ItemRenamer, and only hide the attributes on the client. You can test this yourself - simply select an item in your hotbar, and type the following commands:
    Code:
    /renamer select hand
    /renamer add enchantment NO_ATTRIBUTES 1
    Still, you might be able to work around the unreliability by reapply the effect whenever it is the target of an inventory event, at least in survival mode. In that case, I suggest using my NbtFactory drop-in class, instead of depending on CraftBukkit:
    Code:java
    1. private ItemStack removeAttribute(ItemStack stack) {
    2. // May need to clone this ItemStack as a CraftItemStack
    3. ItemStack craftStack = NbtFactory.getCraftItemStack(stack);
    4.  
    5. NbtFactory.fromItemTag(craftStack).put("AttributeModifiers", NbtFactory.createList());
    6. return craftStack;
    7. }
     
  20. Offline

    amhokies

    Is there a missing word there?
     
    uyuyuy99 likes this.
Thread Status:
Not open for further replies.

Share This Page