Development Assistance Custom ShapelessRecipe not Registering

Discussion in 'Plugin Help/Development/Requests' started by Tailbiter, Mar 17, 2015.

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

    Tailbiter

    I'm compiling against bukkit-1.8.3-R0.1-SNAPSHOT.jar and this is my code.

    Code:
    package org.caudimordax.diamantina;
    
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapelessRecipe;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Diamantina extends JavaPlugin {
        public void onEnable() {
    
            ItemStack coalBucket = new ItemStack(Material.DIAMOND);
            ShapelessRecipe makeBucket = new ShapelessRecipe(coalBucket);
            makeBucket = makeBucket.addIngredient(1, Material.COAL_ORE)
                    .addIngredient(1, Material.CARROT);
            getServer().addRecipe(makeBucket);
    
        }
    
        public void onDisable() {
    
        }
    }
    This is my plugin.yml

    Code:
    author: Tailbiter
    database: false
    main: org.caudimordax.diamantina.Diamantina
    name: Diamantina
    startup: postworld
    version: 1.2
    description: Craftable diamonds!
    I have changed the item values to something else for debug purposes (carrots and coal_ore). I cannot get anything to happen. Server log prints :


    [​IMG]


    All help appreciated. Thanks in advance.
     
  2. Offline

    mine-care

    Pretty weird, are you sure your onenable fires? What server version are you using?
     
    Tailbiter likes this.
  3. Offline

    Tailbiter

    The server reports being :

    I'll add a logger and see if it fires.

    EDIT:

    After having appended
    Code:
    getServer().getLogger().log(Level.INFO, "Firing onEnable!");
    to the onEnable() method I get the following:

    So it seems that the method is being called. I guess I must be doing something wrong with my recipe adding?
     
    Last edited: Mar 17, 2015
  4. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
  5. Offline

    mine-care

    @Tailbiter Dont forget to tagh me! :) thank @Tailbiter for liking my post above that made it show in my alerts :p
    Anyway, your registering of the recipe seems ok! now it looks even weirder!
     
  6. Offline

    Hackbaellchen

    Try to use this:

    Code:
    @Override
    public void onEnable() {
    setRecipes();
    }
    
        public void setRecipes() {
        ItemStack coalBucket = new ItemStack(Material.DIAMOND);
        ShapelessRecipe makeBucket = new ShapelessRecipe(coalBucket);
        makeBucket.addIngredient(Material.COAL_ORE);
        makeBucket.addIngredient(Material.CARROT);
        Bukkit.addRecipe(makeBucket);
    
     
  7. Offline

    Tailbiter

    I rewrote it to what @Hackbaellchen suggested, @mine-care
    Code:
    package org.caudimordax.diamantina;
    
    import java.util.logging.Level;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapelessRecipe;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Diamantina extends JavaPlugin {
        public void onEnable() {
            setRecipes();
            getServer().getLogger().log(Level.INFO, "Firing onEnable!");
    
        }
    
        public void setRecipes() {
            ItemStack coalBucket = new ItemStack(Material.DIAMOND);
            ShapelessRecipe makeBucket = new ShapelessRecipe(coalBucket);
            makeBucket.addIngredient(Material.COAL_ORE);
            makeBucket.addIngredient(Material.CARROT);
            Bukkit.addRecipe(makeBucket);
        }
    
        public void onDisable() {
    
        }
    }
    Seems I'm still having no luck. Everything builds cleanly, the jar is fine.
    [​IMG]


    Here's the decompiled class: http://www.mobilefish.com/customer/tmp/decompiler/hr52824_created.html
     
  8. Offline

    Hackbaellchen

    I think I found the error! You have to use Material.CARROT_ITEM for this crafting recipe. CARROT is the block itself.
     
Thread Status:
Not open for further replies.

Share This Page