Custom Recipes with lores

Discussion in 'Plugin Development' started by tobiyas, Dec 12, 2013.

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

    tobiyas

    Hey,

    I am searching for a possibility to add a lore on an Item (for example Sword or Axe) by putting the Item and another item (somthing like a enchanted book) into a Crafting bench.

    So I want to add a lore to an Item wich is defined by the other item put in the Craftingbench.
     
  2. Offline

    i3ick

  3. Offline

    Developing

  4. Offline

    desht

    Both of these responses miss the point of the original question, which wasn't about adding lore or creating a custom recipe, but how to copy the lore from one of the ingredients to the resulting item.

    You'll need to use the CraftItemEvent to do this. From that event, you can use getRecipe() to get the Recipe for this event and check if it's your custom recipe. If it is, then:
    • Use getInventory() to get the CraftingInventory
    • Find your item with custom lore in the crafting matrix (inventory.getMatrix()) and extract the lore
    • Get the resulting item with inventory.getResult(), and create a new ItemStack from that item and the lore you extracted
    • Put the new item back in with inventory.setResult()
     
    NathanWolf and tobiyas like this.
  5. Offline

    tobiyas

    This is what i was searching. Thank you very much.
     
Thread Status:
Not open for further replies.

Share This Page