How do i get ItemMeta of MaterialData?!

Discussion in 'Plugin Development' started by HyKurtis, Aug 8, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    HyKurtis

    I am trying to be able to get the item meta for the MaterialData so i can make it that you have to have a peice of obsidian named "&7Obsidian Casing" in order to complete the craft. Any help?

    public void obsidiancasing() {
    ItemStack obsidiancasing = new ItemStack(Material.STONE, 1);
    MaterialData data = new MaterialData(Material.OBSIDIAN);
    ItemMeta obcasing = (ItemMeta) data.getItemMeta();
    ShapedRecipe pbrecipe = new ShapedRecipe(obsidiancasing);
    pbrecipe.shape(
    "PPP",
    " ",
    " ");
    pbrecipe.setIngredient('P', data);
    Bukkit.getServer().addRecipe(pbrecipe);
    }
     
  2. Offline

    AcePilot10

    First off, you can paste code with this button: http://prntscr.com/82fgtt . You don't need MaterialData. Instead use the ItemMeta from your ItemStack. Then change the display name of the ItemMeta. Make sure you set the ItemStack to meta too! Example:
    Code:
    ItemStack i = new ItemStack(Material.DIAMOND_SWORD);
    //Meta variable
    ItemMeta meta = i.getItemMeta();
    //set the display name
    meta.setDisplayName(ChatColor.RED + "My Epic Sword");
    //add the data to the item
    i.setItemMeta(meta);
     
Thread Status:
Not open for further replies.

Share This Page