Crafting recipes... need help

Discussion in 'Plugin Development' started by Unfooishly, Feb 25, 2014.

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

    Unfooishly

    I'm marking a crafting recipes plugin but I don't know how to and currently I'm working on monster spawner recipes
     
  2. Offline

    Heirteir

    Unfooishly
    Dude this is the worst thing to ever put. please just go on youtube and put in.
    "How to make a crafting recipe plugin with bukkit"
    This is just such a badly formatted question i don't even care to give time to answer it.
    please take time next time.
    thank you.
    and as i look at the plugins you have made there is one that literally has crafting recipes in it that makes me question if you made it.
     
  3. Offline

    Unfooishly

    Code:
    ShapedRecipe eMan =New ShapedRecipe(new ItemStack(Material.MONSTER_SPAWNER));
       eMan.shape(new String[]{"|||", "|!|", "|||"}).setIngredient('|', Material.IRON_BAR).setIngredient(ENDER_PEARL);
       Bukkit.getServer().addRecipe(eMan);
    Sorry about that, I missed click on since I'm writing this on my phone but this is that right their is the code I have for the mobspawner what I'm wondering us if it possible to set the ItemStack to be a mobspawner for a certain entity.... Again sorry for not specifying enough... Thank you for you time
     
  4. Offline

    Heirteir

    Unfooishly
    Code:java
    1. ItemStack b = new ItemStack(Material.MOB_SPAWNER);
    2. CreatureSpawner cs = (CreatureSpawner) b;
    3. cs.setSpawnedType(EntityType.ENDERMAN);
    4. ShapedRecipe eMan = new ShapedRecipe(b);
    5. eMan.shape(new String[]{"|||", "|!|", "|||"}).setIngredient('|', Material.IRON_INGOT).setIngredient('!', Material.ENDER_PEARL);
    6. Bukkit.getServer().addRecipe(eMan);


    this is an example i created from you original code.
    hope it helped
    also sorry for my outburst :l
     
  5. Offline

    Jake6177


    First of all, quit being so high and mighty. You're not God, and you never will be. Stop trying to act like it. Be nice. We've all been at the stage where we didn't know what to do and we all have never appreciated being talked down to and quite frankly I'm sick of how this community treats prospective developers.

    Now...

    There are two types of recipes: Shapeless and Shaped. A shapeless recipe is a recipe where the shape in the crafting grid is not enforced. Basically just put in the items, in any order, and it'll make the item. A shaped recipe is the opposite of this. It's shape matters, and when it matches, will make the item.

    To make one, you need to do something like this. I won't write the code you want, but I will give an example.

    Shapeless:
    Code:java
    1. ShapelessRecipe recipe1 = new ShapelessRecipe(new ItemStack(Material.WOOD, 1));
    2. recipe.addIngredient(6, Material.SAND);

    ^will, when you put 6 sand into a crafting table (in any order), give you 1 wood.

    Shaped:
    Code:java
    1. ShapedRecipe recipe2 = new ShapedRecipe(new ItemStack(Material.WOOD, 1));
    2. recipe.shape("sss", "s s", "sss");
    3. recipe.addIngredient('s', Material.SAND);

    ^will, when you put 6 sand into a crafting table in a box shape (with no middle), give you 1 wood.

    Once you've done these, you need to tell Bukkit to load it (in onEnable):
    Code:java
    1. Bukkit.addRecipe(recipe1);
    2. Bukkit.addRecipe(recipe2);


    And that's it. :)

    For future reference, use the JavaDocs. The things I used to refresh my mind for these two classes were:

    Shapeless: http://jd.bukkit.org/rb/apidocs/org/bukkit/inventory/ShapelessRecipe.html
    Shaped: http://jd.bukkit.org/rb/apidocs/org/bukkit/inventory/ShapedRecipe.html

    edit: Sorry, Heirteir for the outburst. Didn't see you apologized, as I was busy typing.
     
  6. Offline

    Unfooishly

    Thank you for the help, I really appreciate it, but Heirteir can you explain how the code you added works so I can understand for future recipes please
     
  7. Offline

    Jake6177

    ItemStack b = new ItemStack(Material.MOB_SPAWNER);
    ^make an ItemStack, b, that is a Mob Spawner.

    CreatureSpawner cs = (CreatureSpawner) b;
    ^make a CreatureSpawner, cs, that is b casted to CreatureSpawner.

    cs.setSpawnedType(EntityType.ENDERMAN);
    ^set the CreatureSpawner's spawning type to an Enderman. You can change this to other monsters too.

    ShapedRecipe eMan = new ShapedRecipe(b);
    ^make a ShapedRecipe, eMan, that will give "b". (not sure if that's what needs to be done Heirteir ?)

    eMan.shape(new String[]{"|||", "|!|", "|||"}).setIngredient('|', Material.IRON_INGOT).setIngredient('!', Material.ENDER_PEARL);
    ^set eMan's shape to three iron ingots on top, one iron ingot on the left, one ender pearl in the center, and one iron ingot on the right, and three iron ingots on bottom.

    Bukkit.getServer().addRecipe(eMan);
    ^add the recipe to the server (in onEnable())
     
  8. Offline

    Heirteir

    Unfooishly
    Code:java
    1. ItemStack b = new ItemStack(Material.MOB_SPAWNER);
    2. CreatureSpawner cs = (CreatureSpawner) b;
    3. cs.setSpawnedType(EntityType.ENDERMAN);
    4.  

    Alright This part here is saying that the ItemStack MOB_SPAWNER is going to spawn the entity type of an ENDERMAN.
    Code:java
    1.  
    2. ShapedRecipe eMan = new ShapedRecipe(b);
    3. eMan.shape(new String[]{"|||", "|!|", "|||"}).setIngredient('|', Material.IRON_INGOT).setIngredient('!', Material.ENDER_PEARL);
    4. Bukkit.getServer().addRecipe(eMan);

    This is just creating the recipe for the server and saying that when they put it all together that's going to create the Itemstack b.
    hope this helped

    Jake6177
    thanks i suck at explaining things

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

    Unfooishly

    Ok, I understand now thank you I understand how works now. Thank you guys for all your help.

    quick question do I follow that same method to add more mob spawner... Sorry thus still new to this (YouTube doesn't teach everything) and don't know if it's just as simple as changing some variables in the Heirteir provided me
    Code:
    ItemStack b = new ItemStack(Material.MOB_SPAWNER);
    CreatureSpawner cs = (CreatureSpawner) b;
    cs.setSpawnedType(EntityType.ENDERMAN);
     
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  10. Offline

    Me4502

    For the record, I don't believe that bukkit supports ItemMeta in the recipe result.
     
  11. Offline

    Unfooishly

    So since Me4502 is correct about not be able itemMeta to crafting results is there a way to add a command so the user can change the the spawner ItemMeta?
     
  12. Offline

    Me4502


    The way CraftBook does it, is basically in the Pre-Crafting event, just check the recipe and then set the result if its the correct one.
     
  13. Offline

    Unfooishly


    Can you give give me an example because I really dont understand
     
  14. Offline

    Me4502

Thread Status:
Not open for further replies.

Share This Page