Solved Crafting recipe with custom items

Discussion in 'Plugin Development' started by knokko, Sep 28, 2018.

Thread Status:
Not open for further replies.
  1. With the option in resource packs to let the texture and model of items depend on the damage value and unbreakable flag, it should be possible to more or less create custom items with a bukkit plug-in and server resource pack.

    I am planning to use this, but I encountered an annoying problem: custom crafting recipes

    I should probably add my custom crafting recipes with Bukkit.addRecipe() which takes a crafting recipe as parameter.
    It looks like I should use ShapedRecipe or ShapelessRecipe for this. I decided to check ShapedRecipe first.
    I can set the ingredients of the recipe with the setIngredient and setShape methods. The setIngredient method does not take an ItemStack as parameter, but a MaterialData. It seems like MaterialData can only have a Material and a data (which seems deprecated).

    So how can I add extra requirements to the ingredients?
    Does anyone know a proper way to do it?

    In case there is no better way, I could probably add a custom crafting system or use events to mess around with the recipes, but I am afraid that would be asking for trouble. (But I will do it if that is really the only way...)
     
  2. Offline

    Zombie_Striker

    @knokko
    Since minecraft assumes all crafting recipes simply need materials in a certain order, and does not need to check for lore or displaynames, only materials are support by base recipes.

    To add support for custom items, you would need to register the recipe by just the material types, and then listen to PrepareItemCraftEvent. If the recipe is the same as the one you are checking for, check if the lores/displaynames are correct for the itemstack. If they are, do nothing. But if any of them are not what they should be, set the 'result' to be equal to AIR so players cannot craft it.
     
  3. Thank you for the quick reply.

    I was afraid this would be the case and your idea seemed like my best back-up, so I will try that.
    Also, thanks for giving me the right event to use, that should spare me some searching.
     
Thread Status:
Not open for further replies.

Share This Page