Solved Spawn a chest with items?

Discussion in 'Spigot Plugin Development' started by CrazyTaco, Jul 16, 2018.

  1. Hey! So, I've been trying to spawn a chest with some items in it. Other thread recommended doing this

    Block block = loc.getBlock();
    loc.getBlock().setType(Material.CHEST);
    Chest chest = (Chest)block.getState();
    Inventory inv = ((InventoryHolder) chest).getInventory();

    ItemStack test = new ItemStack(Material.STONE);

    inv.addItem(test);

    But I get the error: https://gyazo.com/6b3e43a7478f16caa122d6b96906ee6b

    I haven't been able to find anymore information on the subject. Does anyone have any clues?
     
  2. Soultion: I used the import for a chest material opposed to a chest block (facepalm)
     
    • Like Like x 1