Solved How to check if a item ID exists.

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

  1. Offline

    Kicksy

    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

    Kicksy

  4. 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.
     
  5. 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.
     
  6. Offline

    CraftCreeper6

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

    Strahan

    I figured that was obvious, heh.
     
  8. Offline

    Kicksy

    Ohh Thanks!
     

Share This Page