ItemMetadata

Discussion in 'Resources' started by Minecraft Coder, Oct 8, 2015.

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

    Minecraft Coder

    Hey guys! this is my first post. Today i made this small and simple way to add your custom metadata-like to itemstack. this way uses NBTTag.
    Download file here:
    EDIT by Timtower: mediafire download removed

    - How to use:
    - Add the file to your project.
    - Create an ItemStack and name it for example item.
    - Create a new instance of ItemMetadata like that:
    Code:
    ItemMetadata itemM = new ItemMetadat(ItemStack);
    - To add a metadata:
    Code:
    itemM.addMetadata(String name, String value);
    Then:
    Code:
    item = itemM.getItem();
    - To check if the item has metadata:
    Code:
    itemM.hasMetadata(String name);
    - To get the value use any of these ways:
    Code:
    itemM.getMetadataAsString(String name);
    Code:
    itemM.getMetadataAsInt(String name);
    Code:
    itemM.getMetadataAsFloat(String name);
    Code:
    itemM.getMetadataAsDouble(String name);
    Code:
    itemM.getMetadataAsLong(String name);
    Code:
    itemM.getMetadataAsIntArray(String name);
    Code:
    itemM.getMetadataAsBoolean(String name);
    ....
    ....
    Please give me your opinion.
     
    Last edited by a moderator: Oct 8, 2015
  2. This is not a Bukkit tool but more of a Util.
    Moved to Resources.
     
  3. Offline

    crolemol

    i wrote i system like this myself depending on Comphenix' NBTLibrary and i did not get any problems yet so it seems like we can store data on itemstacks
     
  4. Offline

    Minecraft Coder

    How can you do that? There's no metadata for itemStack.
     
  5. Offline

    Lolmewn

    How can you always input a String as metadata and then get an int or similar back? That's just weird. Would maybe be better to just accept an Object and either 1) Store the type and cast on get() or 2) Ask for the type on get() and cast then.
     
  6. Offline

    crolemol

    @Minecraft Coder
    you can store any string you want into the attributes ntb tag which will remain after a reload/startup so you can carry the data on an itemstack. mind that when the itemmeta of the item is recreated by bukkit, it does drop the attributes so you have to work around that but it's possible.

    ps: tag me if you want me to see your messages ;)
     
  7. Offline

    T0pAz7

    Does it works on ItemStack or just Item entity?
     
  8. Offline

    Minecraft Coder

    ItemStack.
     
Thread Status:
Not open for further replies.

Share This Page