DrEinsteinium Posted December 15, 2013 Share Posted December 15, 2013 Hi, I was wondering if it was possible to get the amount of block/item subtypes from an itemstack. For example, wool has x amount of different colors, and the color is dependent on the metadata number behind the ID. How do I get the amount of metadata numbers wool has? Here is my code so far: Essentially, it takes in this list and puts the itemid:meta into an itemstack and adds it to a hashmap along with the extra data given. public void importList(String url) { String response = this.getResponse(url); String[] l = response.split(","); for(int i = 0; i < l.length; i++) { String[] itmid = l[i].split("="); String[] metad = itmid[0].split(":"); boolean all = false; ItemStack item = new ItemStack(Integer.valueOf(metad[0].replace("null", "")), 1, 0); if(metad.length > 1 && metad[1] != null) {if(metad[1].contains("*")) all = true; else item.setItemDamage(Integer.valueOf(metad[1])); } if(all) for(int x = 0; x < item.getItemDamage(); x++) { item.setItemDamage(x); PluginRegistrar.registerYoutube(item, itmid[1]); } else { PluginRegistrar.registerYoutube(item, itmid[1]); } } } For some reason, the item.getMaxDamage() method does not work for this and I am not sure why. However, it does work for items such as tools that have thousands of different damage values in their metadata. Thanks. Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img] Link to comment Share on other sites More sharing options...
GotoLink Posted December 16, 2013 Share Posted December 16, 2013 There is no obvious way to get something like this. That value isn't run nor store anywhere. I'd go with using on a new list: Item#getSubItems(int,CreativeTabs,List) then get the list size. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.