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.
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
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.
@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