Help With Custom Recipes!!!

Discussion in 'Plugin Development' started by Proffesor_Diggi, Jul 30, 2015.

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

    Proffesor_Diggi

    Hey there, two things.
    1. I have made a recipe to make an iron bar that is ment to act as a recipe itself and I do not know how to make it if the player places the custom named iron bar, it cancels the event. Please teach me how to do this.
    2. Is it possible to make a custom recipe with custom named items? e.g 5 gold ingots named 'Test' will make a diamond named 'Test 2'. If so, please teach mee.
    Thanks in advance,

    Diggi
     
    Last edited: Jul 30, 2015
  2. Offline

    SuperSniper

    @Proffesor_Diggi

    For the custom names, you can use a preset itemstack instead of doing just a material type

    @Proffesor_Diggi
    Also, can you show us the code you already have made?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  3. Offline

    Proffesor_Diggi

    I did set an item stack

    And Sure, here is the code:
    Code:
    package me.Proffesor_Diggi.cc.Test;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    public class Test extends JavaPlugin {
        // Don't worry about the config stuff, it all works
        @Override
        public void onEnable(){
            saveDefaultConfig();
            if(getConfig().getBoolean("Chain")){
                ItemStack Chain = new ItemStack(Material.IRON_FENCE, 1);
                    ItemMeta ChainMeta = Chain.getItemMeta();
                    ChainMeta.setDisplayName("§fChain");
                    Chain.setItemMeta(ChainMeta);
                    Chain.addUnsafeEnchantment(Enchantment.THORNS, 1);
               
                    ShapedRecipe Chain1 = new ShapedRecipe(Chain)
                            .shape(" - ", "/ /", " - ")
                            .setIngredient('-', Material.COBBLESTONE)
                            .setIngredient('/', Material.IRON_INGOT);
               
                    Bukkit.addRecipe(Chain1);
    
            }else{
                Bukkit.broadcast(ChatColor.RED + "Chain Helmet Crafting is Disabled!", "op");
            }
        }
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
            return false;
        //    if(cmd.getName().equalsIgnoreCase("ctu-reload")){
        //        if(!sender.isOp()){
        //            sender.sendMessage(ChatColor.RED + "Sorry, you do not have permission to do this.");
        //        }
        //            saveDefaultConfig();
        //            sender.sendMessage(ChatColor.GREEN + "Craft The Uncraftable config reloaded.");
        //    }
        //    return false;
        }
    
    }
    
     
  4. Offline

    SuperSniper

    Chain.setItemMeta(ChainMeta);
    Chain.addUnsafeEnchantment(Enchantment.THORNS, 1);

    Switch those around, set the enchantments and everything BEFORE setting the itemmeta

    ALSO: add enchantments through ChainMeta, not the actual itemstack
     
  5. Offline

    Proffesor_Diggi

    Thanks.
    But please help me with my 2 main questions
     
Thread Status:
Not open for further replies.

Share This Page