[Solved] Giving items some data

Discussion in 'Spigot Plugin Development' started by playyip, Jun 26, 2015.

  1. I have this code
    Code (Text):

            ItemStack l = new ItemStack(Material.CARPET);
            // ERROR BELOW
            l.setData(14);
            ItemMeta item = l.getItemMeta();
         
            item.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Basic Flying Carpet");
            item.setLore(Arrays.asList(ChatColor.BLUE + "Your very own flying carpet,",ChatColor.BLUE + "bought cheap at the local",ChatColor.BLUE + "car boot sale."));
            l.setItemMeta(item);
            Player p = (Player) cs
            p.getPlayer().getInventory().addItem(l);
     
    How can I change the error so it sets the data to 14, to get a red carpet?
     
    #1 playyip, Jun 26, 2015
    Last edited: Jun 26, 2015
  2. You should really post the error along with this but my guess is that you need to cast the 14 to a short?
     
  3. Nope, and the error is: int cannot be converted to MaterialData
     
  4. Code (Java):
    new ItemStack(Material.CARPET, (byte)1, (byte)14);
    Creates a stack of 1 red carpet.
     
  5. Thx dude that helped so much!