Solved How to check if a item ID exists.

Discussion in 'Plugin Development' started by Kicksy, Nov 28, 2019.

Thread Status:
Not open for further replies.
  1. I want to check if an item ID exists. Is there a way without creating a long id list manually?
     
    Last edited: Nov 28, 2019
  2. Offline

    CraftCreeper6

    @Kicksy
    Minecraft has a maximum number of item ids, so just check that the item ID is less than or equal to 2267 (in the latest version)
     
  3. Offline

    CraftCreeper6

    @Kicksy
    Do the same thing, but also include a list of missing IDs, if the ID is in the missing list, or is greater than the maximum item ID, then it's invalid.
     
  4. Offline

    Strahan

    You could create an ItemStack using the ID then check if the resultant is of type AIR. If it is, it's a bad id.
     
  5. Offline

    CraftCreeper6

    @Strahan
    Unless the ID is 0, in which case, they wanted air.
     
  6. Offline

    Strahan

    I figured that was obvious, heh.
     
Thread Status:
Not open for further replies.

Share This Page