Solved Get all items from creative inventory

Discussion in 'Spigot Plugin Development' started by finnbon, Apr 13, 2017.

  1. Hello people,

    I've searched via google for an answer to this question, but I couldn't find anything, sadly. What I want to do is retrieve all ItemStacks found in the creative inventory. Either in one of the regular tabs (not the inventory tab), or the everything in the search tab.

    Why? I need a list of all materials that can be made into itemstacks (so not stationary water, stationary lava, fire, etc). Getting all items from the creative inventory will exclude a few blocks, but I'm fine with that. If there is another/better way to get all materials that can be made into itemstacks, please let me know! I've tried to see if I could just go over the Material enum, but it looks way too long.

    Thanks in advance.

    - Finn
     
    • Like Like x 1
  2. So after some more research it seems like this is simply impossible, sadly. Setting to solved I guess.
     
    • Like Like x 1
  3. You could try Material.values() and remove the fews that dont appear creating your own list/array
     
  4. It seems it's not even possible to check if it would appear in the creative inventory sadly, so I'm going to manually write a blacklist now and post it as a resource once I'm done.
     
    • Agree Agree x 1
  5. Ok, I haven't tried this and it's going to be super ugly, BUT if you really want it looks like you could figure this out via reflection.

    1. Iterate overall Material values
    2. Retrieve the NMS Block instance for each Material, via CraftMagicNumbers.getBlock
    3. Get the creativeModeTab property of the Block (via reflection, it's a private field), I assume if this is non-null then it appears in the creative inventory.

    .. seems like it should work, but like I said I haven't tried it so I don't know for sure.
     
    • Useful Useful x 1
  6. This is definitely worth a shot, thanks a lot.
     
    • Friendly Friendly x 2
  7. So I've tried this and printed the materials where the field is null to a file, but this is what it returned.
    Code (Text):

    AIR
    WATER
    STATIONARY_WATER
    LAVA
    STATIONARY_LAVA
    BED_BLOCK
    PISTON_EXTENSION
    PISTON_MOVING_PIECE
    FIRE
    MOB_SPAWNER
    REDSTONE_WIRE
    CROPS
    SOIL
    BURNING_FURNACE
    SIGN_POST
    WOODEN_DOOR
    WALL_SIGN
    IRON_DOOR_BLOCK
    GLOWING_REDSTONE_ORE
    REDSTONE_TORCH_OFF
    SUGAR_CANE_BLOCK
    PORTAL
    CAKE_BLOCK
    DIODE_BLOCK_OFF
    DIODE_BLOCK_ON
    HUGE_MUSHROOM_1
    HUGE_MUSHROOM_2
    PUMPKIN_STEM
    MELON_STEM
    NETHER_WARTS
    BREWING_STAND
    CAULDRON
    ENDER_PORTAL
    DRAGON_EGG
    REDSTONE_LAMP_ON
    COCOA
    TRIPWIRE
    COMMAND
    FLOWER_POT
    CARROT
    POTATO
    SKULL
    REDSTONE_COMPARATOR_OFF
    REDSTONE_COMPARATOR_ON
    BARRIER
    STANDING_BANNER
    WALL_BANNER
    SPRUCE_DOOR
    BIRCH_DOOR
    JUNGLE_DOOR
    ACACIA_DOOR
    DARK_OAK_DOOR
    BEETROOT_BLOCK
    GRASS_PATH
    END_GATEWAY
    COMMAND_REPEATING
    COMMAND_CHAIN
    STRUCTURE_VOID
    STRUCTURE_BLOCK
    IRON_SPADE
    IRON_PICKAXE
    IRON_AXE
    FLINT_AND_STEEL
    APPLE
    BOW
    ARROW
    COAL
    DIAMOND
    IRON_INGOT
    GOLD_INGOT
    IRON_SWORD
    WOOD_SWORD
    WOOD_SPADE
    WOOD_PICKAXE
    WOOD_AXE
    STONE_SWORD
    STONE_SPADE
    STONE_PICKAXE
    STONE_AXE
    DIAMOND_SWORD
    DIAMOND_SPADE
    DIAMOND_PICKAXE
    DIAMOND_AXE
    STICK
    BOWL
    MUSHROOM_SOUP
    GOLD_SWORD
    GOLD_SPADE
    GOLD_PICKAXE
    GOLD_AXE
    STRING
    FEATHER
    SULPHUR
    WOOD_HOE
    STONE_HOE
    IRON_HOE
    DIAMOND_HOE
    GOLD_HOE
    SEEDS
    WHEAT
    BREAD
    LEATHER_HELMET
    LEATHER_CHESTPLATE
    LEATHER_LEGGINGS
    LEATHER_BOOTS
    CHAINMAIL_HELMET
    CHAINMAIL_CHESTPLATE
    CHAINMAIL_LEGGINGS
    CHAINMAIL_BOOTS
    IRON_HELMET
    IRON_CHESTPLATE
    IRON_LEGGINGS
    IRON_BOOTS
    DIAMOND_HELMET
    DIAMOND_CHESTPLATE
    DIAMOND_LEGGINGS
    DIAMOND_BOOTS
    GOLD_HELMET
    GOLD_CHESTPLATE
    GOLD_LEGGINGS
    GOLD_BOOTS
    FLINT
    PORK
    GRILLED_PORK
    PAINTING
    GOLDEN_APPLE
    SIGN
    WOOD_DOOR
    BUCKET
    WATER_BUCKET
    LAVA_BUCKET
    MINECART
    SADDLE
    IRON_DOOR
    REDSTONE
    SNOW_BALL
    BOAT
    LEATHER
    MILK_BUCKET
    CLAY_BRICK
    CLAY_BALL
    SUGAR_CANE
    PAPER
    BOOK
    SLIME_BALL
    STORAGE_MINECART
    POWERED_MINECART
    EGG
    COMPASS
    FISHING_ROD
    WATCH
    GLOWSTONE_DUST
    RAW_FISH
    COOKED_FISH
    INK_SACK
    BONE
    SUGAR
    CAKE
    BED
    DIODE
    COOKIE
    MAP
    SHEARS
    MELON
    PUMPKIN_SEEDS
    MELON_SEEDS
    RAW_BEEF
    COOKED_BEEF
    RAW_CHICKEN
    COOKED_CHICKEN
    ROTTEN_FLESH
    ENDER_PEARL
    BLAZE_ROD
    GHAST_TEAR
    GOLD_NUGGET
    NETHER_STALK
    POTION
    GLASS_BOTTLE
    SPIDER_EYE
    FERMENTED_SPIDER_EYE
    BLAZE_POWDER
    MAGMA_CREAM
    BREWING_STAND_ITEM
    CAULDRON_ITEM
    EYE_OF_ENDER
    SPECKLED_MELON
    MONSTER_EGG
    EXP_BOTTLE
    FIREBALL
    BOOK_AND_QUILL
    WRITTEN_BOOK
    EMERALD
    ITEM_FRAME
    FLOWER_POT_ITEM
    CARROT_ITEM
    POTATO_ITEM
    BAKED_POTATO
    POISONOUS_POTATO
    EMPTY_MAP
    GOLDEN_CARROT
    SKULL_ITEM
    CARROT_STICK
    NETHER_STAR
    PUMPKIN_PIE
    FIREWORK
    FIREWORK_CHARGE
    ENCHANTED_BOOK
    REDSTONE_COMPARATOR
    NETHER_BRICK_ITEM
    QUARTZ
    EXPLOSIVE_MINECART
    HOPPER_MINECART
    PRISMARINE_SHARD
    PRISMARINE_CRYSTALS
    RABBIT
    COOKED_RABBIT
    RABBIT_STEW
    RABBIT_FOOT
    RABBIT_HIDE
    ARMOR_STAND
    IRON_BARDING
    GOLD_BARDING
    DIAMOND_BARDING
    LEASH
    NAME_TAG
    COMMAND_MINECART
    MUTTON
    COOKED_MUTTON
    BANNER
    END_CRYSTAL
    SPRUCE_DOOR_ITEM
    BIRCH_DOOR_ITEM
    JUNGLE_DOOR_ITEM
    ACACIA_DOOR_ITEM
    DARK_OAK_DOOR_ITEM
    CHORUS_FRUIT
    CHORUS_FRUIT_POPPED
    BEETROOT
    BEETROOT_SEEDS
    BEETROOT_SOUP
    DRAGONS_BREATH
    SPLASH_POTION
    SPECTRAL_ARROW
    TIPPED_ARROW
    LINGERING_POTION
    SHIELD
    ELYTRA
    BOAT_SPRUCE
    BOAT_BIRCH
    BOAT_JUNGLE
    BOAT_ACACIA
    BOAT_DARK_OAK
    TOTEM
    SHULKER_SHELL
    IRON_NUGGET
    GOLD_RECORD
    GREEN_RECORD
    RECORD_3
    RECORD_4
    RECORD_5
    RECORD_6
    RECORD_7
    RECORD_8
    RECORD_9
    RECORD_10
    RECORD_11
    RECORD_12
     
    A few of them are correct, and do not appear in the creative inventory, but a lot of these actually do appear in the creative inventory.
     
  8. I went through the list by hand and removed the incorrect materials. Here's the result:
    Code (Text):

    AIR
    WATER
    STATIONARY_WATER
    LAVA
    STATIONARY_LAVA
    BED_BLOCK
    PISTON_EXTENSION
    PISTON_MOVING_PIECE
    FIRE
    MOB_SPAWNER
    REDSTONE_WIRE
    CROPS
    SOIL
    BURNING_FURNACE
    SIGN_POST
    WALL_SIGN
    IRON_DOOR_BLOCK
    GLOWING_REDSTONE_ORE
    REDSTONE_TORCH_OFF
    SUGAR_CANE_BLOCK
    PORTAL
    CAKE_BLOCK
    DIODE_BLOCK_OFF
    DIODE_BLOCK_ON
    HUGE_MUSHROOM_1
    HUGE_MUSHROOM_2
    PUMPKIN_STEM
    MELON_STEM
    NETHER_WARTS
    BREWING_STAND
    CAULDRON
    ENDER_PORTAL
    DRAGON_EGG
    REDSTONE_LAMP_ON
    COCOA
    TRIPWIRE
    COMMAND
    FLOWER_POT
    CARROT
    POTATO
    SKULL
    REDSTONE_COMPARATOR_OFF
    REDSTONE_COMPARATOR_ON
    BARRIER
    STANDING_BANNER
    WALL_BANNER
    WOOD_DOOR
    SPRUCE_DOOR
    BIRCH_DOOR
    JUNGLE_DOOR
    ACACIA_DOOR
    DARK_OAK_DOOR
    BEETROOT_BLOCK
    GRASS_PATH
    END_GATEWAY
    COMMAND_REPEATING
    COMMAND_CHAIN
    STRUCTURE_VOID
    STRUCTURE_BLOCK
    COMMAND_MINECART
    END_CRYSTAL
    DRAGONS_BREATH
     
    Solved!
     
    • Like Like x 1
    • Informative Informative x 1
  9. Hey!
     
  10. Those are the actual blocks, not the items (I was confused too). ;)
     
    • Informative Informative x 2
    • Agree Agree x 1