Add Recipe

Discussion in 'Plugin Development' started by Rudigorn, Sep 10, 2011.

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

    Rudigorn

    Hi,
    a short time ago I wanted to write my own bukkit-plugins, an easy one at the beginning, something like adding a few recipes to minecraft, that schould already exist in my opinion, without adding new blocks.
    But I see, it's not as easy as I thought.
    I'm able to use a plugin on my server, that's no problem. To add new recipes (If only the number of items is important) I use CraftShapelessRecipe, I think. But is there a manual how to use it?
    I found "Bukkitdoc", but that's not what I looked for. I need some examples or an explanation that shows me where to use it and what it does exactly.

    Sincerely,
    Rudigorn

    EDIT: I have a little experience in coding, but it's enough to understand most plugin codes.
     
  2. Offline

    badcc

    Hello,
    Here is what I have been using


    Code:
            final ShapedRecipe glass = new ShapedRecipe(new ItemStack(Material.GLASS, 4));
            glass.shape("A", "B");
            glass.setIngredient('A', Material.SAND);
            glass.setIngredient('B', Material.COAL);
    It's very simple to use, This makes 4 Pieces of Glass, Take Sand and put it on top, and Coal on the bottom and 4 pieces of glass comes out.
    .shape("XXX", "XXX", "XXX");
    That is the 3x3 crafting table.
    The first "XXX" is the top row, 2nd is the second row, and so on.
    If you want it to be blank in an area, just do a space

    .shape("X ", " X ", " X");

    that will make something that looks like this
    100
    010
    001
    Pretend that is a 3x3 crafting grid, 0's are AIR 1's are BLOCKS or the "X"'s

    As you can see this is very easy, if you need anymore help just ask!

    :D Hope you can find this useful :)
     
  3. Offline

    Rudigorn

    Yes, seems to be easy :D, thanks. I guess for shapeless recipes, i write shapeless instead of shaped and delete the second line?
    That's everything I have to write in the onEnabled function to get a new recipe?
     
  4. Offline

    badcc

    I'm not sure about the shapeless recipe, I have not used it, but yes, just put that in the onEnabled function
     
  5. Offline

    Rudigorn

    ok, i'll try it :) Thank you for your help.
    EDIT: Now I need white dye (bone meal) as a material, what must I do? Maybe with changing damage of Material.INK_SACK to 15?
     
  6. Offline

    enjikaka

    I can't get it to work. Am I doing this right?

    Code:
    package enji.lep.misc;
    
    import java.util.logging.Logger;
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    
    /* Created by enji */
    
    public class Random extends JavaPlugin {
        public final Logger logger = Logger.getLogger("Minecraft");
    
        @Override
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info("Lightweight Essential Plugin - " + pdfFile.getName() + " Edition " + pdfFile.getVersion() + " enabled.");
            final ShapedRecipe grass = new ShapedRecipe(new ItemStack(Material.GRASS, 1));
            grass.shape("A", "B");
            grass.setIngredient('A', Material.SEEDS);
            grass.setIngredient('B', Material.DIRT);
        }
    
        @Override
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info("Lightweight Essential Plugin - " + pdfFile.getName() + " Edition " + pdfFile.getVersion() + " disabled.");
        }
    
    }
    
     
  7. you can do the following:

    Code:
    Dye d = new Dye();
    d.setColor(DyeColor.WHITE); // or d.setColor((byte) 15)
    this.getServer().addRecipe(new Shaped Recipe(d.toItemStack(64))...);
    you need to complete the last line but you get the idea.


    you need to add the following line to the end of onEnable()
    Code:
    this.getServer().addRecipe(grass);
    you never added it to the server you just made the recipe
     
Thread Status:
Not open for further replies.

Share This Page