Solved ItemMeta on recipe ingredient

Discussion in 'Plugin Development' started by Ne0nx3r0, Jan 14, 2013.

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

    Ne0nx3r0

    I'd like to make a recipe where a user can add charges to an item with custom itemmeta.

    So for example they might put the item on the crafting screen surrounded by four glowstone to add a charge.

    The item would be "crafted", but would retain the original itemmeta regardless of what it was, with the charge count in the lore altered.

    Is this possible?
     
  2. Offline

    chasechocolate

    InventoryClickEvent of or CraftItemEvent
     
  3. Offline

    Ne0nx3r0

    Serendipitiously I stumbled across the answer answering someone else's post:
    Code:
        @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
        public void onCraftItem(PrepareItemCraftEvent e)
        {
            ItemStack bow = new ItemStack(Material.BOW, 1);
            ItemMeta item = bow.getItemMeta();
            item.setDisplayName("Bow of Fish");
            
            ArrayList<String> lore = new ArrayList<String>();
            lore.add("FISHEY!!!!!");
            
            item.setLore(lore);
            bow.setItemMeta(item);
     
            e.getInventory().setResult(bow);
        }
    
    chasechocolate As you said, basically :)
     
Thread Status:
Not open for further replies.

Share This Page