Custom Crafting Recipes with Renamed Items.

Discussion in 'Plugin Development' started by MineCrypt, May 29, 2013.

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

    MineCrypt

    Alright guys, I have a quick issue. I have the code that allows me to make a custom recipes. But I want to make it so you can only craft those recipes with a certain item that has been renamed.

    So here's the whole thing.
    I have a recipe that makes a sword called Mystic Sword.
    But I want it so you can only craft the "Mystic Sword" if you use items that have a certain display name
    The certain display name would be dropped by mobs, but thats not to worry about here.

    So the main thing is, I have a custom crafting recipe but I want it only to work with renamed items that I choose the names for.

    Recipe Code:
    Code:
    ShapedRecipe recipe = new ShapedRecipe(MysticSword).shape("obo", "obo", "oso")
                    .setIngredient('b', Material.DIAMOND_BLOCK)
                    .setIngredient('s', Material.STICK);
    There'es more to the recipe code, but that's all I think is really important
     
  2. Offline

    Minnymin3

    make an event handler checking on prepare craft event and then check to see if the recipe result is the same as your result and then check if item in slot whatever is your renamed item. If it is then cancel the event. Slots in crafting table are 0-8 I think (not sure):
    0,1,2
    3,4,5
    6,7,8
     
  3. Offline

    MineCrypt

    Alright, I've been playing around with this and I pretty much almost got it to work, the only problem being is how do you cancel this type of event? I cant do event.setCancelled or anything
     
  4. Offline

    Minnymin3

    Event.setresult(null)
     
  5. MineCrypt
    Checking for recipe result is not 100% reliable because other plugins can add recipes too... and some plugins can add user-defined custom recipes that might want to make your result with diferent ingredients, and you'll be forcing names on those ingredients as well.

    I suggest checking for ingredients+result combination to be 100% sure it's your recipe, here's an utility class for that: http://forums.bukkit.org/threads/ut...e-with-permissions-restricted-recipes.144319/
     
Thread Status:
Not open for further replies.

Share This Page