1.15.2 Iterate over all possible Material

Discussion in 'Spigot Plugin Development' started by El_Fantomas, Mar 28, 2020.

  1. Hi,

    I was using
    Code (Text):
    Material.values()
    which should return me all the instance of the Material Enum but instead return me few items as show bellow. Does anyone has any clues of how to solve this problem ? (I want to iterate over all possible item and block in the game)

    Code (Text):
    [11:49:00] [Server thread/WARN]: AIR
    [11:49:00] [Server thread/WARN]: STONE
    [11:49:00] [Server thread/WARN]: GRASS
    [11:49:00] [Server thread/WARN]: DIRT
    [11:49:00] [Server thread/WARN]: COBBLESTONE
    [11:49:00] [Server thread/WARN]: WOOD
    [11:49:00] [Server thread/WARN]: SAPLING
    [11:49:00] [Server thread/WARN]: BEDROCK
    [11:49:00] [Server thread/WARN]: WATER
    [11:49:00] [Server thread/WARN]: STATIONARY_WATER
    [11:49:00] [Server thread/WARN]: LAVA
    [11:49:00] [Server thread/WARN]: STATIONARY_LAVA
    [11:49:00] [Server thread/WARN]: SAND
    [11:49:00] [Server thread/WARN]: GRAVEL
    [11:49:00] [Server thread/WARN]: GOLD_ORE
    [11:49:00] [Server thread/WARN]: IRON_ORE
    [11:49:00] [Server thread/WARN]: COAL_ORE
    [11:49:00] [Server thread/WARN]: LOG
    [11:49:00] [Server thread/WARN]: LEAVES
    [11:49:00] [Server thread/WARN]: SPONGE
    [11:49:00] [Server thread/WARN]: GLASS
    [11:49:00] [Server thread/WARN]: LAPIS_ORE
    [11:49:00] [Server thread/WARN]: LAPIS_BLOCK
    [11:49:00] [Server thread/WARN]: DISPENSER
    [11:49:00] [Server thread/WARN]: SANDSTONE
    [11:49:00] [Server thread/WARN]: NOTE_BLOCK
    [11:49:00] [Server thread/WARN]: BED_BLOCK
    [11:49:00] [Server thread/WARN]: DIAMOND_AXE
    [11:49:00] [Server thread/WARN]: STICK
    [11:49:00] [Server thread/WARN]: BOWL
    [11:49:00] [Server thread/WARN]: MUSHROOM_SOUP
    [11:49:00] [Server thread/WARN]: GOLD_SWORD
    [11:49:00] [Server thread/WARN]: GOLD_SPADE
    [11:49:00] [Server thread/WARN]: GOLD_PICKAXE
    [11:49:00] [Server thread/WARN]: GOLD_AXE
    [11:49:00] [Server thread/WARN]: STRING
    [11:49:00] [Server thread/WARN]: FEATHER
    [11:49:00] [Server thread/WARN]: SULPHUR
    [11:49:00] [Server thread/WARN]: WOOD_HOE
    [11:49:00] [Server thread/WARN]: STONE_HOE
    [11:49:00] [Server thread/WARN]: IRON_HOE
    [11:49:00] [Server thread/WARN]: DIAMOND_HOE
    [11:49:00] [Server thread/WARN]: GOLD_HOE
     
    Thank you,

    Paul
     
  2. After further investigation it seems that the values return by the method are Legacy one (we can see STATIONARY_WATER which is only present as a legacy value in the Material Enum). The point is that I really need to iterate over all posssible item and block and this should have worked... Is there another method to access this list ?
     
  3. What doesn't work?
    Material.values() returns an array Material
     
  4. You are missing an api-version >_<
     
    • Agree Agree x 1