Jump to content

Getting the subtype amount for itemstacks


DrEinsteinium

Recommended Posts

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.

Follow me on twitter! @keepablock

Read up on whats new! www.catacombs.co

width=700 height=60http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.